I'm working with a project that requires nested forms to add multiple valves to a single order (order is called rfq in this case).
I get this error:
ActionView::Template::Error (uninitialized constant Rfq::Valf):
48: </div>
49:
50: <div id="valves">
51: <%= f.fields_for :valves do |valve| %>
52: <%= render 'valve_fields', f: valve %>
53: <% end %>
54: <%= link_to_add_association 'add valve', f, :valves %>
Here's relevant part of the form partial,
<%= form_for @rfq do |f| %>
...
<div class="field">
<%= f.label :application %><br>
<%= f.text_field :application %>
</div>
<div id="valves">
<%= f.fields_for :valves do |valve| %>
<%= render 'valve_fields', f: valve %>
<% end %>
<%= link_to_add_association 'add valve', f, :valves %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Valve fields partial:
<div class="nested-fields">
<div class="field">
<%= f.label :line %>
<%= f.text_field :productline %>
</div>
<%= link_to_remove_association "remove valve", f %>
</div>
RFQ model:
class Rfq < ActiveRecord::Base
has_many :valves
accepts_nested_attributes_for :valves, :allow_destroy => true
belongs_to :customer
has_paper_trail
end
Valve model:
class Valve < ActiveRecord::Base
belongs_to :rfq
has_paper_trail
end
Thanks in advance
Try specifying your "Valve" class name as illustrated below.