Can't mass-assign protected attributes

后端 未结 4 417
一整个雨季
一整个雨季 2021-02-05 02:53

Updating the code formatting for better viewing.

Folks,

I have been looking at this for sometime but I don\'t understand what could be messing up here. I am usin

相关标签:
4条回答
  • 2021-02-05 03:16

    Nowadays (April 2013) you should start to use https://github.com/rails/strong_parameters

    0 讨论(0)
  • 2021-02-05 03:20

    Inside of SpecificModel (appfolder/app/model/specific_model.rb)

    Try using

    attr_accessible :addresses_attributes, :another_attribute_to_make_mass_assignable, :another_attribute, etc.

    0 讨论(0)
  • 2021-02-05 03:27

    Just include the datafield in the model as mentioned below

    attr_accessible :addresses_attributes
    
    0 讨论(0)
  • 2021-02-05 03:29

    Have a look here and learn :)

    http://railscasts.com/episodes/26-hackers-love-mass-assignment


    Edit:

    Having accepts_nested_attributes_forin User model enables you to send the data to the Address model.

    Then, in the Address model, you have to set the requested attr_accessible

    0 讨论(0)
提交回复
热议问题