mercredi 6 mars 2019

Delete has_one id associate with has_many primary key?

I have 2 models :

class Agency < ApplicationRecord

has_one :branding

end


class Branding < ApplicationRecord

has_many :agencies

end

when I was destroying any branding, it still keeps its key with the Agency, where I made a field "branding_id".

I want something which nullifies it when any branding got to destroy in the process. It automatically updates the agency branding_id to null.

Aucun commentaire:

Enregistrer un commentaire