Skip to content

Instantly share code, notes, and snippets.

@soniaprevost
Last active March 17, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soniaprevost/d592115ac88ce75504f4 to your computer and use it in GitHub Desktop.
Save soniaprevost/d592115ac88ce75504f4 to your computer and use it in GitHub Desktop.
Tracker les changements des instances
# sur tous les attributs
person.changes # => { "name" => ["bill", "bob"] }
# vérifier s'il y a eu un changement sur l'instance
person.changed? # => false
# récupérer la valeur changée
person.name_was # => "Uncle Bob"
Et plein d'autres => 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