-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Use SQL trigger to implement destroy dependent. ex:
CREATE TRIGGER article_comment_association_dependent_destroy
AFTER DELETE ON articles
FOR EACH ROW BEGIN
DELETE FROM comments WHERE private_id = (
SELECT private_id FROM article_comment_associations
WHERE article_id = OLD.private_id;
)
END;Article and comment models are like this:
define :article do
has_many :comments, :dependent => :destroy
end
define :comment do
belongs_to :article
end