I have a method that is called after the creation of an object
after_create :send_welcome_email
Is there a way to limit this to a condition, su
There are three ways to do this: Symbol, String, or Proc.
class User < ActiveRecord::Base
after_create :send_welcome_email, unless: :is_celebrant?
after_create :send_welcome_email, unless: "is_celebrant?"
after_create :send_welcome_email, unless: Proc.new { self.role == "Celebrant" }
end
Documentation