Open DevArenaCN opened 7 years ago
On which part of the code is this failing?, I would say on the if
, but what is the user
variable value at that point?
So when the email does not exist in the ActiveRecord, it will throw out a 500 internal server error instead of a 422 Invalid email or password error.
I think the user variable is nil, somehow, can you confirm this?
I can verify the login if the user exist in the database, which I don't think it's nil, right?
I think you are getting the 500
because of this user.valid_password? user_password
I'm not sure but it can be that the user is nil, so is trying to execute valid_password?
over nil...it should not happen though...
I'm working on the log in with sessions_controller, so my create function looks like this:
So when the user does not exist, I got a 500 error instead of a 422. Any ideas? I tried
rescue ActiveRecord::RecordNotFound
but it's not working for me.