I would like to create a before_save callback that only gets run if there have been changes to any (but not necessarily all) of the three fields (street, city, state). How do you do this? Thanks
user.rb
class User
before_save :run_test_method, :if => street_changed?
...
end
Option One
You could create a method like:
and then use:
Note how
:ok_to_run_test_method?is a symbol. Not sure if it was a typo or not but in your question you are actually calling a class methodstreet_changed?.Option Two
Modernise your callbacks a little bit and use the block-style syntax: