4f0354303f
Simplify channels & user controllers and models, moving code to the models. Remove catch-all route and ensure all actions are specified, fixing url paths. Change clone to dup in feed_controller as using clone seems to affect the cloned object (problem only in ruby 1.9.3?)
14 lines
357 B
Ruby
14 lines
357 B
Ruby
module KeyUtilities
|
|
|
|
# generates a database unique api key
|
|
def generate_api_key(size = 16)
|
|
alphanumerics = ('0'..'9').to_a + ('A'..'Z').to_a
|
|
k = (0..size).map {alphanumerics[Kernel.rand(36)]}.join
|
|
|
|
# if key exists in database, regenerate key
|
|
k = generate_api_key if ApiKey.find_by_api_key(k)
|
|
|
|
# output the key
|
|
k
|
|
end
|
|
end |