So I have an after_update callback in an ActiveRecord model to notify an external service. This should only be called if a couple of attributes are being updated. So I encapsulated the saved_change_to_attribute? calls in a method that is then used in the callback filter:
after_update :tell_service!, if: :update_for_service?
def update_for_service?
saved_change_to_name? ||
saved_change_to_city?
end
Now update_for_service? always returns false and I don't understand why.
In the console:
> p = Person.last
> p.name = 'Tom'
> p.save
true
> p.saved_change_to_name?
true
> p.update_for_service?
false
What is going on here?