Skip to content

Instantly share code, notes, and snippets.

@szalansky
Created September 2, 2015 09:12
Show Gist options
  • Save szalansky/55424e7d4a5c50559228 to your computer and use it in GitHub Desktop.
Save szalansky/55424e7d4a5c50559228 to your computer and use it in GitHub Desktop.
product = Product.find 123
product.title = “foo”
product.changed? # true
######
product = Product.find 123
product.title = “foo”
product.changed? # true
product.save # no matter if it succeeds or not
product.changed? # false
product.previous_changes["title"].nil? # false (shows all values of attribute since it has been fetched from the DB and instantiated)
# vide http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment