ruby - _destroy isn't working in Coocon gem with Rails 4 -
i have same issue one
but solution didn't me. here strong params:
def request_params params.require(:request).permit(:name, :address, :phone, :mobile, :type, :filled_cartridges_attributes => [:cartridge_name,:client_id,, :count,:_destroy,:id],
so have :_destroy , :id. guy in previous forgot add :id strong params. adding id solved problem.
here request model:
has_many :filled_cartridges, inverse_of: :request, dependent: :destroy accepts_nested_attributes_for :filled_cartridges, :reject_if => :all_blank, allow_destroy: true
and how params after submitting:
request: ...some params.... filled_cartridges_attributes: !ruby/hash:actioncontroller::parameters '0': !ruby/hash:actioncontroller::parameters cartridge_name: hp laserjet3000 _destroy: 'false' id: '1' '2': !ruby/hash:actioncontroller::parameters cartridge_name: new 9 _destroy: '1' id: '13'
here 2nd 1 should destroyed. doesn't.
you should add :_destroy , :id on permitted parameters specified nested attribute.