“after_create for sti rails” Kode Jawaban

after_create for sti rails

after_create : create_coupons_for_existing_users, unless: :discounted_coupon?
Annoying Armadillo

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
Annoying Armadillo

after_create for sti rails

def create_coupons_for_existing_users
  return unless self.type == "DiscountedCoupon"
  # your logic here
end
Annoying Armadillo

after_create for sti rails

def discounted_coupon?
  self.type == "DiscountedCoupon"
end 
Annoying Armadillo

Jawaban yang mirip dengan “after_create for sti rails”

Pertanyaan yang mirip dengan “after_create for sti rails”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya