Loading...
This quick little method makes it really easy to pull up a specific user in your app, just call User[:login] and you have them! I use it primarily in script/console.
class User < ActiveRecord::Base def User.[](key) if key.is_a?(Integer) User.find_by_id(key) else User.find_by_login(key.to_s) end end end
Comments
No one has commented on this yet.
You must be logged in to post a comment.