>To Add custom conditions to authlogic finders first of all we need to override authlogic find_by_login method.
class UserSession < Authlogic::Session::Base
after_validation :check_if_verified
find_by_login_method :find_by_login_and_deleted_method
end
Then we need to define overridden method inside User model
class User < ActiveRecord::Base
acts_as_authentic
def self.find_by_login_and_deleted_method(login)
find_by_email_and_deleted(login, false)
end
end
got easy..wooooooo 🙂
I had a similar issue and I found the same solution but I’m having problem while passing two arguments to the overriden method.
I want to pass one more argument which is necessary for finding the user.
I can’t access or get that parameter in model.
Please let me know if you have some solution to it.
Hi Nitin,
First, you need to change model method to accept second parameter. I guess you already made those changes. Regarding not able to access second parameter in model, How you passing second parameter from controller..?
Wherever find_by_login is used, change it to pass second parameter –
User.find_by_login(param1, param2)