I'm using Rails polymorphic associations, that way some models have many cash_histories
children, like this:
has_many :cash_histories, as: :cashable
But when I try to delete all cash histories from a parent @resource
, like this:
@resource.cash_histories.delete_all
I get the following query:
UPDATE "cash_histories" SET "cashable_id" = NULL WHERE "cash_histories"."cashable_id" = $1 AND "cash_histories"."cashable_type" = $2 [["cashable_id", 1], ["cashable_type", "ServiceOrder"]]
I can't understand this behavior, setting relationship id to null instead of removing, that will result in dead rows in my table. Why is that happening?
I'm using Rails 4.1.