I have this line in my controller:
user = User.any_of({:user_name => login}, {:email => login})
if user.nil?
# ...
elsif user.legacy_password.nil?
And it creates this error:
undefined method `legacy_password' for []:Array
Why would this happen? the user object is supposed to be nil. At least that is what the debugger said.
I’m assuming your
any_ofmethod returns an array of results, not a single result. You probably want to add.firstto the end of it, which will give you either a User record, ornilifany_ofreturned an empty array.