Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tiegz/9748836 to your computer and use it in GitHub Desktop.
Save tiegz/9748836 to your computer and use it in GitHub Desktop.
Example for Rails 4 Timestamp/Callback order regression.
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