Plugins - ActiveRecordChanged

StarAdd to favorites

Additions to ActiveRecord:
.changed? – have model attributes changed since save?
.saved? – have all attributes been saved to the database? (opposite of .changed?)
Simple! it keeps track of whether or not an ActiveRecord model has attributes that have changed since the last save.
Notes:
– New records are treated as changed, even if no attribute has explicitly been set.
– “saved?” is the opposite of “changed?”
examples:
>> sam = Person.find_by_name(‘sam’)
>> sam.changed?
=> false
>> sam.saved?
=> true
>> sam.age = 24
=> 24
>> sam.changed?
=> true
>> sam.saved?
=> false
>> sam.save
>> sam.saved?
=> true
Steven Soroka
http://www.clearlinewebsystems.ca

Steven Soroka

svn://svn2.clearlinewebsystems.ca/public/plugins/active_record_changed/

OpenSource

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
knox 26 Nov 2007

whats the difference to acts_as_modified?

Peter 2 Oct 2007

The "dirty" plugin does the same thing except is a bit more fleshed-out...

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?