I worked on a plugin called acts_as_modified a while ago, it works by
storing a copy of the original @attributes hash. I use this to be able
to send notification emails containing the changes, including the
original values, when objects are updated.

http://svn.viney.net.nz/things/rails/plugins/acts_as_modified

Seeing the discussion on this list I've put together acts_as_changed,
which stores a list of the changed attributes as they are modified. It
also only save attributes that have been changed. This plugin should
be more lightweight than acts_as_modified, but I haven't done any
performance tests.

http://svn.viney.net.nz/things/rails/plugins/acts_as_changed

Both plugins freeze the attributes when they are read. I wasn't able
to check out the existing patches because trac is down, so I'm not
sure how they compare with previous implementations.

Meanwhile, back on topic, can someone apply the original patch? :)

-Jonathan.

On 7/30/06, Michael Koziarski <[EMAIL PROTECTED]> wrote:
> Performance hurt. Having write_attribute mark dirty[attr] = true
> would be great, but attributes may be modified in-place once they're
> read, so we have to hash or copy them and look for changes.
>
> A seductive alternative to is to treat attribute values as immutable
> - freeze the value returned from read_attribute. Then we're on easy
> street.

It's more than just dirty[attr] = true,  as most rails apps will be
calling attributes= or update_attributes which will flag as dirty,
every attribute in the form, irrespective of whether or not the value
changes.

The whole thing is high risk,  low reward.   Sounds perfect for a plugin! ;)



--
Cheers

Koz
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to