I have the same issue as this one
But that solution didn't help me. Here are my 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 i have :_destroy and :id. The guy in the previous forgot to add :id to strong params. Adding an id solved his problem.
Here is my 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 this is how params look like 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 the 2nd one should be destroyed. But it doesn't.