ruby on rails - Rake Aborted: Can't mass-assign protected attributes -
I try to migrate the data imported via seed assistant to rake db: seed
I do
A rake works (01_roll), but the second rake (02_conditions) says there are large-scale protected features.
Fixtures / Evolution / 01_Rolls. Rb
SeedHelper.make_roles
Fixtures / Development / 02_conditions.rb
SeedHelper.make_conditions
seed_helper. RB
Singleton DF self.make_roles in class seed helper file_path = "# {Rails.root} / db /roles.csv" RoleImporter :: import (file_path) end Def self.make_conditions file_path = "# {Rails.root} /db/conditions.csv" ConditionEmporter :: Import (file_path) end and
model / condition.rb
condition of the category & lt; ActiveRecord :: Base attr_accessible: condition,: bodypart,: description end
I'm thinking that this is calling the first stability (01_roles) because that file has a "description" variable and It is not saying this as an error:
can not assign protected attributes: condition, bodypart
model / role .rb
Where do I change the rake file or importer to read the correct file?
The answer was found:
I need the to import Condition_importer '
must be added to RB
Then in condition_importer.rb, I have Role.create!
instead of Condition.create!
via duplicate the file:
class conditionimportor deff self.import (file_path) CSV.readlines (file_path, {: headers =>: first_row ,: encoding = & Gt; 'UTF-8'}). Every do Row | Term ['Description']) End End
Comments
Post a Comment