Reputation: 8563
I implemented authlogic for my authentication system. I was hoping if there was a method to log in users by "username" OR "email" . The solution provided here http://goo.gl/Ato1 doesn't work as I don't have a "login" field in the database.
So is it that, I am missing the "login" field in the db? OR is there any other way of handling it?
Login should happen by Username OR email...
Upvotes: 1
Views: 1385
Reputation: 10564
Did you try this:
class UserSession < Authlogic::Session::Base
find_by_login_method :find_by_username_or_email
end
and in user.rb
def self.find_by_username_or_email(login)
find_by_username(login) || find_by_email(login)
end
#note login is only the parameter name and does not refer to your model
Upvotes: 9