Last active
August 29, 2015 13:57
-
-
Save tiegz/9748836 to your computer and use it in GitHub Desktop.
Example for Rails 4 Timestamp/Callback order regression.
This file contains hidden or 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
class Thing < ActiveRecord::Base | |
before_update :skip_record_timestamps | |
def skip_record_timestamps | |
self.record_timestamps = false | |
return true | |
end | |
after_update :reset_record_timestamps | |
def reset_record_timestamps | |
self.record_timestamps = true | |
end | |
end | |
# This passed in Rails 3, but not Rails 4. | |
t = Thing.find(1) | |
expected = t.updated_at | |
t.update_attributes(name: 'new name') | |
assert_equal expected, t.updated_at |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment