フィールドa_field
の変更前の値はa_field_was
で取得できるので,例えば"値が変更されていたら実行する"という処理は,after_updateの中で以下のように書いてやればいい
my_model.rb
class MyModel < ActiveRecord::Base
after_update do
do_something if a_field != a_field_was
end
end
More than 5 years have passed since last update.
フィールドa_field
の変更前の値はa_field_was
で取得できるので,例えば"値が変更されていたら実行する"という処理は,after_updateの中で以下のように書いてやればいい
class MyModel < ActiveRecord::Base
after_update do
do_something if a_field != a_field_was
end
end
Register as a new user and use Qiita more conveniently