Nested attributes - Unpermitted parameters Rails 4

后端 未结 2 1049
谎友^
谎友^ 2021-01-25 19:33

There is a lot of resources on SO about issues on Nested attributes in Rails 4 regarding strong parameters but I don\'t find any solution on this: (so sorry if it\'s a duplicate

相关标签:
2条回答
  • 2021-01-25 20:11

    Try Adding the :member_id inside profile_attributes which is in member_params

    so it will look like this:

    def member_params
          params[:member].permit(:email, profile_attributes: [:first_name, :last_name, :member_id ])
    end
    
    0 讨论(0)
  • 2021-01-25 20:13

    Ok get it..

    I think this is caused by simple_form:

    = simple_form_for [:admin, @member] do |f|
      = f.simple_fields_for :profile, @member.profile do |pf|
        = pf.input :first_name
        = pf.input :last_name
      = f.input :email
      = f.button :submit
    
    0 讨论(0)
提交回复
热议问题