Moved here
I discovered what I believe to be a bug in activerecord (2.1.0) today. If you have something like the following:
:person_address, :dependent => :destroy
end
has_one :person
end
belongs_to
...and you have for foreign key constraint on person_address_id on the person table to id on the person_address table (which would be a reasonable thing to do) you will get a foreign key constraint error when you try to destroy a person record (if the associated person_address record exists).
I submitted a patch to rails for this, but in the meantime, I found this as a work around:
:person_address # note: no :dependent => :destroy
super() # first destroy ourselves before we destroy the association
PersonAddress.destroy(self.person_address_id) if self.person_address_id
end
end
belongs_to
No comments:
Post a Comment