Hi,
I have a doubt that has persisted for a time.
I have a form of Placa that has multiple nested forms that are loaded by
ComponenteDePlaca partials.
class Placa < ActiveRecord::Base
has_many :componente_de_placas, :dependent => :destroy
accepts_nested_attributes_for :componente_de_placas, :reject_if =>
lambda { |a| a[:nome].blank? }, :allow_destroy => true
end
class ComponenteDePlaca < ActiveRecord::Base
belongs_to :placa
end
On form of Placa I made as follows:
<%= form_for(@placa, :html => { :multipart => true }) do |f| %>
…
<%= f.label :componente_de_placas, "Director" %>
<% f.fields_for :componente_de_placas do |builder| %> <%= render "director_fields", :f => builder %> <% end %><%= f.label :componente_de_placas, "Coordinator" %>
<% f.fields_for :componente_de_placas do |builder| %> <%= render "coordinator_fields", :f => builder %> <% end %>The coordinator_fields have an attribute with different value of the
director_fields that is passed by a hidden.
That way the create works.
My problem is the update view. In f.fields_for: componente_de_placas
director, it build the both(director and coordinator) in div of
director, and the same happen for fields_for of the coordinator.
Does anyone know how to fix it?
Thanks!