Search code examples
ruby-on-railsrakedevise

Cannot create Devise account using rake db:seed for Rails 3.0


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 => 'nnn@gmail.com',
                        :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

Solution

  • 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 => 'nnn@gmail.com', :password => 'foobar', :password_confirmation => 'foobar', :first_name => 'nn', :last_name => 'yy')
    

    Try that.