This project is archived and is in readonly mode.
Changeset [54c963c89b81cfc4fd7dcad6779e41c85d1180ce] by Murray Steele
Revision 54c963c89b81cfc4fd7dcad6779e41c85d1180ce,
committed by Murray Steele
· March 23rd, 2011 @ 09:45 PM
Make clearing of HABTM join table contents happen in an after_destory callback.
The old method of redefining destroy meant that clearing the
HABTM join table would happen as long as the call to destroy
succeeded. Which meant if there was a before_destroy that stopped
the instance being destroyed using normal means (returning false,
raising ActiveRecord::Rollback) rather than exceptional means the
join table would be cleared even though the instance wasn't
destroyed. Doing it in an after_destroy hook avoids this and has
the advantage of happening inside the DB transaction too.
https://github.com/rails/rails/commit/54c963c89b81cfc4fd7dcad6779e4...
1 changed file
-
M
activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb