This project is archived and is in readonly mode.

Changeset [5d43977c7c76a76adfffdafa3de2e739216dab81] by Murray Steele

March 23rd, 2011 @ 09:34 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/5d43977c7c76a76adfffdafa3de2e...

Committed by Murray Steele

  • M activerecord/lib/active_record/associations.rb

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>