This project is archived and is in readonly mode.

Changeset [80989437dc1502f9194b0600941b6d70a3efa3b2] by Josh Sharpe

August 31st, 2009 @ 06:50 PM

I added this feature so that a Map of changed fields could be retrieved
after a model had been saved. This is useful in the after_save callback
when you need to know what fields changed. At present there is no way
to do this other than have code in the before_save callback that takes
a copy of the changes Map, which I thought was a bit messy.

Example.

person = Person.find_by_name('bob') person.name = 'robert' person.changes # => {'name' => ['bob, 'robert']} person.save person.changes # => {} person.previous_changes # => {'name' => ['bob, 'robert']} person.reload person.previous_changes # => {}

Signed-off-by: Joshua Peek josh@joshpeek.com
http://github.com/rails/rails/commit/80989437dc1502f9194b0600941b6d...

Committed by Josh Sharpe

  • M activemodel/lib/active_model/dirty.rb
  • M activerecord/lib/active_record/attribute_methods/dirty.rb
  • M activerecord/test/cases/dirty_test.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>