I’ve been following the tutorial on the Devise github page here: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address
I’m in the second part of the tutorial where we allow users to recover their password using either their username or email and there’s a large block of code that the tutorial says to copy into the User model. This is the line that throws an error:
def self.find_record(login)
where(attributes).where(["username = :value OR email = :value", { :value => login }]).first
end
This is the error I get:
NameError (undefined local variable or method `attributes' for #<Class:0xa70e1a8>):
app/models/user.rb:63:in `find_record'
app/models/user.rb:44:in `find_recoverable_or_initialize_with_errors'
app/models/user.rb:30:in `send_reset_password_instructions'
Anyone know why this error is showing up?
You’re not passing in any attributes, and there’s no ‘attributes’ class method, so
where(attributes)doesn’t work. It doesn’t look like you need to either. Change your method to:For what it’s worth, I don’t see how it would have worked in the tutorial either.