@user has null value and login fails

Continuing the discussion from Ruby-mri is consuming lots of memory:

I am moving this part of the topic because now it is a new problem.

The value of the instance variable (@user) is not related to your database.
It is being set here by the ‘login’ method; which, I would assume, makes a call to the database.

What is the code in the login method?
Where is that method defined?
Looking at the log output do you see an attempt to dip into the database?