Skip to content

Instantly share code, notes, and snippets.

@sunchess
Created July 18, 2017 16:01
Show Gist options
  • Select an option

  • Save sunchess/80af5e656dc3ba4bdb73d8b6490dcd4e to your computer and use it in GitHub Desktop.

Select an option

Save sunchess/80af5e656dc3ba4bdb73d8b6490dcd4e to your computer and use it in GitHub Desktop.
Пояснения по dirty методам
#rails <= 5.0
user = User.new(name: "Bob")
user.save
user.changed_name? #true
user.update_attribute(:name, "Alice")
user.changed_name? #true
#rails >= 5.1
user = User.new(name: "Bob")
user.save
user.saved_change_to_name? #false
user.will_save_change_to_name? #true
user.update_attribute(:name, "Alice")
user.saved_change_to_name? #true
user.will_save_change_to_name? #false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment