Answers for "after_create for STI rails"

0

after_create for STI rails

after_create : create_coupons_for_existing_users, unless: :discounted_coupon?
Posted by: Guest on January-29-2021
0

after_create for STI rails

def discounted_coupon?
  self.type == "DiscountedCoupon"
end
Posted by: Guest on January-29-2021
0

after_create for STI rails

def create_coupons_for_existing_users
  return unless self.type == "DiscountedCoupon"
  # your logic here
end
Posted by: Guest on January-29-2021
0

after_create for STI rails

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
Posted by: Guest on January-29-2021

Browse Popular Code Answers by Language