After_Create pour STI Rails
after_create : create_coupons_for_existing_users, unless: :discounted_coupon?
Annoying Armadillo
after_create : create_coupons_for_existing_users, unless: :discounted_coupon?
module Concerns::CouponDistribution
extend ActiveSupport::Concern
included do
after_create :create_coupons_for_existing_users, if: Proc.new {|cd| cd.type == "DiscountedCoupon" }
end
def create_coupons_for_existing_users
#
end
end
def create_coupons_for_existing_users
return unless self.type == "DiscountedCoupon"
# your logic here
end
def discounted_coupon?
self.type == "DiscountedCoupon"
end