ryanb/nested_form — Issue #120: nested model/nested model, attribute does not show up
Author: chabgood
Created: 2011-11-24 01:01:43+00:00
State: open

I have a problem - has many solutions, solution has one product, Here is the solutions partial, whe I click add solution from the problem form this form shows up BUT the product name atribute does not show up but all of the solution attributes show up as inputs idea?

Problem form,
<%= nested_form_for @problem do |f| %>
<%= f.error_messages %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :height %>
<%= f.text_field :height %>
<%= f.label :weight %>
<%= f.text_field :weight %>
<%= f.label :age %>
<%= f.text_field :age %>
<%= f.label :note %>
<%= f.text_area :note, :size => '10X20' %>

Solution partial:

<%= f.fields_for :solutions %>

<%= f.link_to_add 'Add a solution', :solutions %>
<%= f.submit 'Save' %>
<% end %>

Solutions

<%= f.fields_for :product do |p| %>

<%= p.label :name %>
<%= p.text_field :name %>

<% end %>

<%= f.label :how_many %>
<%= f.text_field :how_many %>

<%= f.label :how_much %>
<%= f.text_field :how_much %>

<%= f.label :how_often, 'How Often, per/' %>
<%= f.select :how_often, Product::How_often %>

<%= f.label :details %>
<%= f.text_area :details, :size => '30X6' %>

<%= f.label :bad_stuff, "No Bad Stuff?" %>
<%= f.check_box :bad_stuff %> <%= link_to_function "show", "$('#bad_stuff_text').toggle();" %>

<%= Solution.bad_stuff.html_safe %>

<%= link_to_remove_fields "remove", f %>