views:

169

answers:

1

I'm working on some code that uses a lot of after_save callbacks, and I remember seeing a plugin that allows the model.changes array to persist after a call to save.

It would be a great help if I could just write if body_did_change? in my after_save calls, instead of having to hack together something with a before_save filter just to set a flag.

I have written something like this myself before, but I'd prefer to use something supported and I swear I've seen this plugin before.

+1  A: 

I believe it is built-in now - a recent feature. I have been using it in my project.. See http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects

vectran
Yeah, I need something that will persist after calling `save` though. As it is now, my `after_save` callbacks don't know which attributes changed prior to the `save` call.
Luke
Wow, my bad. It seems that does actually work in `after_save` calls! The last time I tried this was ~6 months ago and either it's a new addition or I screwed something up earlier. Thanks!
Luke