Я использую вложенную форму gem с rails 4. link_to_add работает отлично.link_to_remove не работает.Он удаляет новую вложенную форму из dom, но фактически не удаляет объект.Моя модель - кампания, а моя вложенная форма - из модели с именем accessory.
Campaign.rb
has_many :accessories, :dependent => :destroy
accepts_nested_attributes_for :accessories, :reject_if => :all_blank, allow_destroy: true
Accessory.rb
belongs_to :campaign
Campaigns_controller.rb
params.require(:campaign).permit(:product_name, :product_description, :accessories_attributes => [ :id, :name, :description, :_destroy ])
Application.js
//= require jquery
//= require jquery_ujs
//= require tinymce
//= require jquery_nested_form
//= require cosmo/bootswatch
//= require_self
new.html.erb
<%= nested_form_for @campaign, :multipart => true do |f| %>
<%= f.text_field :name %>
<%= render 'campaigns/accessories_fields', :f => f %>
<%= f.link_to_add "Add a accessory", :accessories %>
<% end %>
_accessories_fields.html.erb
<%= f.fields_for :accessories do |i| %>
<%= i.text_field :name %>
<%= i.link_to_remove "Remove this accessory" %>
<% end %>