ruby on rails - Unpermitted parameters error -


i trying add nested form in app, shell shows me error:

unpermitted parameter: description 

there model

class chart < activerecord::base   has_many :descriptions   accepts_nested_attributes_for :descriptions end 

there strong params in controller:

  def chart_params     params.require(:chart).permit(:title, descriptions_attributes: [:name])   end 

this form:

= form_for @chart |f|   = f.text_field :title   = f.fields_for :descriptions |d|     = d.text_field :name   = f.submit 

what doing wrong?

upd

i change form , action new in controller

form

 = form_for @chart |f|     = f.text_field :title     = f.fields_for @descriptions |d|       = d.text_field :name     = f.submit 

action new

  def new     @chart = chart.new     @descriptions = @chart.descriptions.build   end 

the name attribute text_field 'name' should 'chart[descriptions_attributes][name]'.

please check code snippet below:

= form_for @chart |f|   = f.text_field :title   = f.fields_for :descriptions_attributes, @descriptions |d|     = d.text_field :name   = f.submit 

no changes required new action of controller.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -