Hey alI,
I like the new support for memoizable methods in Rails 2.2. However, I'm running into a problem that's making it hard to use in my case.
My ActiveRecord model has a method that does a lot of data crunching, and it takes a few seconds. I used ActiveSupport::Memoizable and memoized that long-running method, which made my code quite clean since I can call it willy-nilly from all over my view. Very nice.
The problem happens when I call #destroy on the model. I didn't know much about freezing AR objects, so I was surprised when I found out that #destroy called #freeze, and #freeze called #memoize_all. This calls my long-running method, sadly, which is about the last thing I want to happen when destroying my object!
My work-around was to call ModelClass.delete(id), but that's kinda lame given that it doesn't go through the normal callback cycle - it will surely bite me on the ass someday.
Any other workaround to this problem I don't see? Besides, of course, rolling my own memoization?
Thanks! Mike