I'm trying to preload all devise accounts in advance using rake db:seed. Data for all other models seems to be inserted in the database but for some reason NO rows are created for Person model which uses devise. Registration from web interface works fine, but I want to avoid creating accounts manually, thats the reason i'm using rake db:seed. I copied encrypted_password,password_salt from an account created via web interface. Please let me know how to get around this? Many thanks..
people = Person.create(
:email => '[email protected]',
:encrypted_password => '$2a$10$SyacAOhJQtVeTcTPYm.ROuFbhGMylfj4fLrK3NHyeRwfEokKp2NVW',
:password_salt => '$2a$10$SyacAOhJQtVeTcTPYm.ROu',
:first_name => "nnn",
:last_name => "yyy"
)
in routes.rb i have.
devise_for :people
I've done this using Devise in the past. I didn't try setting the encrypted password and salt that way. I just set the password and confirmation something like this (I dont have my project handy):
Person.create(:email => '[email protected]', :password => 'foobar', :password_confirmation => 'foobar', :first_name => 'nn', :last_name => 'yy')
Try that.
Most likely the "create" method fails quietly due to model validation and therefore returns false. You would've seed the errors if you used "create!" method instead (with exclamation) - this method raises the exception if validation fails.
The likely reason for validation failure in your case is that (by default for Devise) minimum password length is 6 characters and you were not supplying password at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With