Created
July 21, 2012 10:57
-
-
Save erez-rabih/3155431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u = User.create!(:name => "user1", :adderss => "address1", :current_job => "job1") | |
u.address = "address2" | |
u.current_job = "job2" | |
u.current_job_changed? # => true | |
u.address_changed? # => true | |
u.changed? # => true | |
u.changed # => ['address', 'current_job'] | |
u.tracked.current_job_changed? # => false | |
u.tracked.address_changed? # => false | |
u.tracked.changed? # => false | |
u.tracked.changed # => [] | |
u.save! | |
u.current_job_changed? # => false | |
u.address_changed? # => false | |
u.changed? # => false | |
u.changed # => [] | |
u.tracked.current_job_changed? # => true | |
u.tracked.address_changed? # => true | |
u.tracked.changed? # => true | |
u.tracked.changed # => ['address', 'current_job'] | |
u.tracked.set_unchanged(:current_job) | |
u.tracked.current_job_changed? # => false | |
u.tracked.set_changed(:current_job) | |
u.tracked.current_job_changed? # => true | |
u.tracked.set_all_unchanged | |
u.tracked.changed? # => false | |
u.tracked.changed # => [] | |
u.tracked.set_all_changed | |
u.tracked.changed? # => true | |
u.tracked.changed # => ['address', 'current_job'] # note name is not changed - only tracked attributes are marked as changed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment