i'm using devise on rails5 to confirm email address for login. everything works well until i click the confirmation link. then it shows me this error:
NameError in Devise::ConfirmationsController#show
undefined local variable or method `signin' for #< Class:0x007fb1cbe56b48>
this is the code that causes the error:
conditions = warden_conditions.dup
where(conditions).where(["lower(username) = :value OR lower(email)
= :value", { :value => signin.downcase }]).first
end
this is my model that the above code belongs to:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
attr_accessor :signin
validates :username, :uniqueness => {:case_sensitive => false}
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
where(conditions).where(["lower(username) = :value OR lower(email)
= :value", { :value => signin.downcase }]).first
end
can some one help me about it? and if you give me some information about how this method works?
First thing,
attr_accessor
defines an instance method, not a class method, so if you callsignin
inside a class method likeself.find_first_by_auth_conditions
is going to throw you thatundefined local variable or method 'signin' for #< Class:0x007fb1cbe56b48>
error.Second, your
find_for_database_authentication
method is incomplete. You should base according to this example:I'm not sure if you already used that example as base, but if you explain what were your reasons to modify it, it would be great. I there's no reasons, use that piece of code.