Rails Nested Attributes and Model Inheritance -


looking @ example of form_for rails docs, see example:

<%= form_for @person |person_form| %>   first name: <%= person_form.text_field :first_name %>   last name : <%= person_form.text_field :last_name %>    <%= fields_for @person.permission |permission_fields| %>     admin?  : <%= permission_fields.check_box :admin %>   <% end %>    <%= f.submit %> <% end %> 

i tried copying template, noticed in order update work correctly, had change field_for line to

 <%= person_form.fields_for @person.permission |permission_fields| %> 

any idea why showing fields_for without parent form variable in front (person_form)?

the examples later in docs show parent form variable.

thanks

it correct person_form. think of formtag , assign inputs form. names of form set (person[attribute]). fields_for without person_form create other name (permission[admin]) - fail because permission object not connected person. through person_form.fields_for names right (person[permission][admin]). nested attribute without doing more.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -