Sha256: a0ad37d0bd239e659722ac94f6a8640038f939a5a497ab96868678c45b6f0929
Contents?: true
Size: 877 Bytes
Versions: 1
Compression:
Stored size: 877 Bytes
Contents
module Trade module Model::PromoteGood extend ActiveSupport::Concern included do attribute :status, :string, default: 'available' attribute :effect_at, :datetime attribute :expire_at, :datetime belongs_to :promote belongs_to :good, polymorphic: true, optional: true has_many :promote_buyers, dependent: :delete_all scope :verified, -> { where(status: ['default', 'available']) } scope :valid, -> { t = Time.current; verified.default_where('effect_at-lte': t, 'expire_at-gte': t) } enum status: { default: 'default', # 默认直接添加的服务,不可取消 available: 'available', # 可选 unavailable: 'unavailable', # 不可选 specific: 'specific' # 特定的? } validates :promote_id, uniqueness: { scope: [:good_type, :good_id] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_trade-0.0.3 | app/models/trade/model/promote_good.rb |