Rails Guides - Step 11 - Multi Model Form - MassAssignmentSecurity Error

I follow RailsGuide very closely and works fine until step 11. Adding tags via the MultiModel form. As soon as I added the code, I get this error:

ActiveModel :: MassAssignmentSecurity :: Error updating PostsController # Unable to assign protected attributes in bulk: tags_attributes

Application trace: app / controllers / posts_controller.rb: 65: in block in update' app/controllers/posts_controller.rb:64:in update'

I made a backup and started several times to make sure that this is not a user error. Can someone help me go through this step. I'm so close Then I can go to the Hartl tutorial. Thanks.

+4
source share
1 answer

This is not your fault!

The extensive start-up guide is not updated for the default value of Rails 3.2.3

 # in config/application.rb: config.active_record.whitelist_attributes = true 

The fix is ​​to add this to your Post model:

 # in app/models/post.rb class Post < ActiveRecord::Base attr_accessible :tags_attributes ... 

By the way, this entire section has been removed from the source of the manual, which you can find at https://github.com/rails/rails/blob/master/guides/source/getting_started.textile .

+2
source

Source: https://habr.com/ru/post/1412693/


All Articles