Seeding users with Devise in Ruby on Rails
You have to do like this:
user = User.newuser.email = 'test@example.com'user.encrypted_password = '#$taawktljasktlw4aaglj'user.save!
Read this guide to understand what mass-assignment is: http://guides.rubyonrails.org/security.html
I am wondering why do have to directly set the encrypted password. You could do this:
user.password = 'valid_password'user.password_confirmation = 'valid_password'
Arun is right. It's easier just to do this in your seeds.rb
user = User.create! :name => 'John Doe', :email => 'john@gmail.com', :password => 'topsecret', :password_confirmation => 'topsecret'
The skip_confirmation
method will only work if you have confirmable
module in your user model, otherwise remove it.
user = User.new( :email => "admin@xxxxx.xxx", :password => "123456", :password_confirmation => "123456" ) user.skip_confirmation! user.save!