Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1152 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 3 years ago

[PATCH] track attribute changes

Reported by: bitsweat Assigned to: Jeremy Kemper <rails@bitsweat.net>
Priority: normal Milestone:
Component: ActiveRecord Version: 0.11.0
Severity: normal Keywords: dirty change tracking
Cc:

Description

class User < ActiveRecord::Base
  track_changes!

  private
    def after_save
      update_name_in_external_system if name_changed?
    end
end

Only classes declaring track_changes! have the augmented behavior. Enable Rails-wide with ActiveRecord::Base.track_changes! in your environment. Comparison snapshots are taken very lazily so objects which don't use change tracking don't take a performance hit.

The patch is non-invasive (all behavior added by aliasing) and includes unit tests. Forthcoming patches will rely on it to handle database default values correctly and to optimize insert and update statements.

Attachments

dirty.diff (13.7 kB) - added by bitsweat on 04/19/05 16:55:16.

Change History

04/19/05 16:55:16 changed by bitsweat

  • attachment dirty.diff added.

05/09/05 12:06:59 changed by bitsweat

  • status changed from new to closed.
  • resolution set to wontfix.

There doesn't seem to be much popular need for change tracking so I'm closing the ticket rather than bloat Active Record with unused features.