for instance if I want to fetch a url if the url attribute has
I know that I can use before_save and do:
get_url if url_changed?
However, this is not really correct. If that call is using delayed job
or some other technique since the object is not yet saved in the
before_save callback, for instance.
might end up getting the old URL if it is executed before the update
completes. The prior technique would also end up using the new URL if
the update fails. This is the sort of thing that should be done after
the object is updated.
I’d like to do something like:
after_save :get_url, :if => url_changed?
but this won’t work because the url is no longer “dirty” after the
Settings flags in the before_save and executing after_save gets ugly
real fast, and has potential for infinite loops, requiring hackery.
Is there a clean way to do this?