# Model Instance
user = User.first
user.saved_changes?
# => false
user.update!(name: "Alice")
# User Update (0.8ms) UPDATE `users` SET `name` = 'Alice', `updated_at` = '2020-01-26 05:35:18' WHERE `users`.`id` = 1
user.saved_changes?
# => true
user.reload
user.saved_changes?
# => false
# When nothing commit on DB
user.update!(name: "Alice")
# (0.6ms) BEGIN
# (0.5ms) COMMIT
user.saved_changes?
# => false
# Then saved_changess?
user.update!(name: "Bob")
user.saved_changes?
# => true
user.reload
user.saved_changes?
# => false
user.name = "Carol"
user.saved_changes?
# => false
user.has_changes_to_save?
# => true
user.save!
user.saved_changes?
# => true
Ref
Rails 5.1 で attribute_was, attribute_change, attribute_changed?, changed?, changed 等が DEPRECATION WARNING - Qiita
https://qiita.com/htz/items/56798d53ec5988733fc6
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。