Ruby on Rails: Devise

2019-08-11 11:58发布

问题:

I've set up a scaffold for a hypothetical application with a users log in, but run into the following error when I try to create a user using the view

undefined method `encrypted_password=' for #<User:0x007fdffb0303a8>

回答1:

I agree with Sergio. But just to elaborate, follow the instructions below since it seems you may be new to Devise.

Did you do

gem install devise
rails generate devise:install
rails generate devise User
rake db:migrate
rails generate devise:views

?

The full instructions can be found here.



回答2:

You probably forgot to run migrations against your database after you have installed devise. Or there was no such column in the migration.



回答3:

Be sure to have password and passord_confirmation as accessible attributes in your User model like this:

attr_accessible :email, :password, :password_confirmation, etc...