I have a big problem in my applications. It's little complicated so I will try explain it deeply. In my application I have model "Car":
class Car < ActiveRecord::Base
has_many :prices, dependent: :destroy
accepts_nested_attributes_for :prices, allow_destroy: true
end
and "Price":
class Price < ActiveRecord::Base
belongs_to :car
end
Im using wicked gem to have a wizard form. Im also use a cocoon gem to easily create some nested objects.
My "Payment step html":
= simple_form_for [:partners, @car], url: wizard_path do |f|
= f.simple_fields_for :prices do |price|
= render 'price_fields', f: price
#links
= link_to_add_association 'add price', f, :prices
= link_to t('cars.back'), edit_partners_car_path(@car)
= f.submit t('cars.next'), class: 'btn btn-primary'
And price_fields:
.nested-fields
%table.table.table-striped.table-bordered
%thead
%th
= f.input :from_days
%th
= f.input :to_days
%th
= f.input :netto_price
= link_to_remove_association "X", f
And the problem is when I create some prices and go to the next step prices are saved into databse and everything is fine. But when I come back to this step and I click my:
= link_to_remove_association "X", f
it only hide this object but not delete it from database. It's big problem for me. I can't find issue. Please help if You can.