I'm sure - I've got a big chunk of code using _changed? in after_save out in production. The flags are reset after the save operation completes - note that you can still rollback a save in the after_save callbacks by raising an exception.
--Matt Jones On Jul 25, 5:17 pm, Michael Schuerig <mich...@schuerig.de> wrote: > On Saturday 25 July 2009, Matt Jones wrote: > > > You can also use the methods included from ActiveRecord::Dirty on the > > foreign key fields; in your case, you'd have an after_save callback > > like this (on Person): > > > after_save :cleanup_addresses > > > def cleanup_addresses > > Address.destroy(shipping_address_id_was) if > > shipping_address_id_changed? && shipping_address_id_was > > Address.destroy(billing_address_id_was) if > > billing_address_id_changed? && billing_address_id_was > > end > > Matt, have you tried this code? Specifically, are you sure that the > dirty states have not already been reset by the time the after_save > callback is invoked? That was my concern when I suggested using a > before_save callback in a parallel post. > > Michael > > -- > Michael Schuerig > mailto:mich...@schuerig.dehttp://www.schuerig.de/michael/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---