Rails Couldn't find user with auth_token -
i have started rather strange issue rails 3.2.18 app
i using authentication cookies described on railscasts. past year (until upgraded 3.2.18) has been well.
however have following issue. can log on successfully, , navigate few pages. however, after undetermined number of page clicks 500 internal page error. in production log see following error (i have changed actual token code)
activerecord::recordnotfound (couldn't find user auth_token = xxxxxxxxxxxxxx): app/controllers/application_controller.rb:28:in `current_user'
when @ database entry user see correct auth_token entry. line of code being referenced in application controller is
@current_user ||= user.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
so yes, need replce witth rather find_by statement things woork in rails 4, this, don't think, should causing issue, odd inital authentication , few pages clicks work, , doesn't work.
to able login in again have shutdown browser session (i have same on firefox, safari, , ie) , restart , can login period of time.
in addition not issue in development, in production
well in end changed find_by query query follows
original
@current_user ||= user.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
new
@current_user ||= user.where("auth_token =?", cookies[:auth_token]).first if cookies[:auth_token]
and seems have resolved things. thought find_by depricated in rails 4, not totally happy.
Comments
Post a Comment