Last active
August 29, 2015 14:05
-
-
Save cybersamx/e993874a9932f5f6fe03 to your computer and use it in GitHub Desktop.
Update Rails ActiveRecord object without triggering validation and updating updated_at
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
object = MyModel.create(name: 'Sam') | |
# update_attribute bypass validation but will touch update_at | |
object.update_attribute(:name, 'Yo') | |
object.name == 'Yo' # true | |
object.name_changed? # false | |
# update_column bypass validation but will not touch update_at | |
object.update_column(:name, 'Yo') | |
object.name == 'Yo' # true | |
object.name_changed? # false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment