Results 1 to 4 of 4
Thread: NameError in AccessController
Jul 21, 2013, 23:04 #1
- Join Date
- Aug 2011
- 1 Post(s)
- 0 Thread(s)
NameError in AccessController
I have been learning Rails 3 from a video on Lynda.com, and it has been going well up until lately. What i'm trying to do currently is restrict access to certain pages unless a session is present where the user is authorized (has logged in). This is working correctly because when I try to access the pages that I want restricted, I get redirected to the login form. The problem comes up when I try to login. I put the correct username in, but when I put the password in, any password at all, it doesn't even need to be the correct one, I get an error page I made a user admin account for development purposes, and when I login I get this error:
NameError in AccessController#attempt_login
undefined local variable or method `salt' for #<AdminUser:0x41a6a68>
Now, I don't know a ton about debugging as of right now, but based on the trace the method attempt_login in the access controller is the following:
def attempt_login authorized_user = AdminUser.authenticate(params[:username], params[:password]) if authorized_user session[:user_id] = authorized_user.id session[:username] = authorized_user.username flash[:notice] = "You are now logged in." redirect_to(:action => 'menu') else flash[:notice] = "Invalid username/password combination." redirect_to(:action => 'login') end end
I don't know if there is an error in there that I am missing?
Anyway thanks in advance, and let me know if you need more of my code to find a solution because I am totally stuck at this point.