问题
I can't seem to get my User model in Authlogic to understand the 'password' method even though I added "acts_as_authentic" to the model. This problem was also reported on the Authlogic lighthouse, but no one described how they fixed it:
http://binarylogic.lighthouseapp.com/projects/18752/tickets/128-undefined-method-password-on-rails-231#ticket-128-9
The user table exists with all the required fields, and the controllers and everything else is definitely following the tutorial to the letter.
Anyone know what could be wrong?
(Oh, I'm running Rails 2.3.3, Authlogic 2.1.1)
回答1:
I misspelled "crypted_password" as "crypted_passwond". Arg!
For all those other people out there, be sure you have all the required columns in your database.
回答2:
Make sure your User model is using acts_as_authentic
:
#app/models/user.rb
class User < ActiveRecord::Base
acts_as_authentic
end
I did all kinds of troubleshooting and had somehow removed this when I was troubleshooting a different problem.
回答3:
Have you restarted your application since you installed authlogic? With Passenger, touch tmp/restart.txt
will do.
回答4:
I had the same problem and finally realized my route for users was wrong. I had mystyped
map.resources user
when I fixed and changed to this, authlogic recognized the password field
map.resources.users
来源:https://stackoverflow.com/questions/1382723/authlogic-getting-an-undefined-method-password-for-user