UPDATE: I am running on Ruby 1.8. The link to the repository is github.com/lauherk/sample_app
I am going through the Ruby on Rails Tutorial by Micheal hartl, and in chapter 9 I am encountering an issue with populating the db with sample users http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users?version=3.2#sec:sample_users
The code for my rake is:
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
User.create!(:name => "Example User",
:email => "example@railstutorial.org",
:password => "foobar",
:password_confirmation => "foobar")
99.times do |n|
name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(:name => name,
:email => email,
:password => password,
:password_confirmation => password)
end
end
end
after running both:
bundle exec rake db:reset
bundle exec rake db:populate
I get the following error from command line:
rake aborted!
Can't mass-assign protected attributes: Lawrence Kertzmann
/Library/Ruby/Gems/1.8/gems/activemodel-3.2.2/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
(THis specific name changes every time I run the rake)
I have checked and have made sure that in my user model I have the code
attr_accessible :name, :email, :password, :password_confirmation
and have even tried setting
config.active_record.whitelist_attributes = false
Yet, still have the same outcome at command line.
Any tips to get my database populated with sample users?
Thanks very much.