I have an after_update callback in my model
after_update :do_something
However, I don't want the method to be called after an object has been created. Is is possibe to add an exemption to after_update?
Rails has many different callbacks. When you create an object after_create and after_save are called. When you update an existing object, after_update and after_save are called.
after_create is used only on creation as after_update is only for updating existing objects. after_save runs on both cases, after the proper create/update callback.
If you don't want the method to be called only after an object has been created you should use after_create instead.
You could define as many callbacks as you need
class User < ActiveRecord::Base
after_create :one_method
after_create :another_method
after_update :one_more_method_only_for_updates
def one_method
end
def another_method
end
def one_more_method_only_for_updates
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With