ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes

前端 未结 6 1247
一个人的身影
一个人的身影 2020-12-14 01:56

If I try to execute the following code:

hassle = rota.hassles.create(:sender => user1, :receiver => user2, :type => \"sms\")

I oba

6条回答
  •  遥遥无期
    2020-12-14 02:09

    Are you working with Rails 3.2 while following a 3.1 tutorial such as the Pragmatic Programmer's "Agile Web Development with Rails" 4th edition? Then check http://guides.rubyonrails.org/3_2_release_notes.html.

    Your problem is that from Rails 3.1 to 3.2 checking of mass assignment protection for Active Record models is set to 'strict' by default. Comment out the appropriate lines in these files:

    config/environments/development.rb
    config/environments/test.rb
    

    ... and you're good to go on learning. Remember to leave this in effect when coding your first production application :)

提交回复
热议问题