Я использую драгоценный камень кокона (1.2.6) в моем приложении rails 4.1 + activeadmin. link_to_add_association добавила пустые поля с новым в форме ERB. пожалуйста, обратитесь к входному идентификатору ниже
<input id="lease_information_lease_units_attributes_new_lease_units_property_name" type="text" name="lease_information[lease_units_attributes][new_lease_units][property_name]">
когда я нажимаю link_to_add_association, создаются поля с идентификатором.
<input id="lease_information_lease_units_attributes_1420800589434_property_name" type="text" name="lease_information[lease_units_attributes][1420800589434][property_name]">
моя форма rental_informations/_lease_units.html.erb:
<%= javascript_include_tag :cocoon %>
<div id='lease_units'>
<%= f.semantic_fields_for :lease_units do |lease_unit| %>
<%= render 'lease_unit_fields', f: lease_unit %>
<% end %>
<div class='links'>
<%= link_to_add_association image_tag("icon-new.png", height: '18', width: '18'), f, :lease_units, title: "Add Unit" %>
</div>
</div>
частичный _lease_unit_fields.html.erb :
<div class='nested-fields'>
<table>
<tbody>
<tr >
<td class="col col-unit_type">
<%= f.text_field :unit_type %>
</td>
<td class="col col-unit">
<%= f.text_field :unit %>
</td>
<td class="col col-action">
<%= link_to_remove_association image_tag("icon-remove.png", height: '18', width: '18'), f, title: "Remove Unit" %>
</td>
</tr>
</tbody>
</table>
</div>
мой админ/lease_information.rb
ActiveAdmin.register LeaseInformation do
menu false
controller do
def new
@page_title="Data Entry Form"
@lease_information = LeaseInformation.new
# @lease_information.lease_units.build
end
end
form do |f|
tabs do
tab 'Units' do
table_for resource.lease_units do
column :unit_type
column :unit
end
render "lease_units", f: f # rendering the partial here
end
f.actions do
f.action :submit, label: "Submit"
f.cancel_link(admin_jobs_path)
end
end
end
из-за этого вложенные поля не сохраняются в БД. может ли кто-нибудь помочь мне решить эту проблему?
admin/lease_information.rb
, я думаю, это решит вашу проблему. ` ‹td class=col col-action› ‹%= link_to_remove_association image_tag(icon-remove.png, height: '18', width: '18'), f, title: Remove Unit %› ‹/td› ` - person Amit Sharma   schedule 10.01.2015