In my development and test environments, I want to seed the database with a bunch of users. I’m using Ruby on Rails v3.2.8 and the latest Devise. So I added this line in my db/seeds.rb file:
User.create(email: 'test@example.com', encrypted_password: '#$taawktljasktlw4aaglj')
However, when I run rake db:setup, I get the following error:
rake aborted! Can’t mass-assign protected attributes:
encrypted_password
What is the proper way to seed users?
You have to do like this:
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: