Sha256: da139a92c58d675d781b59c4504e7ae16d9cab5b2961849639bb3eae5c2a4596

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

# Order 是订单。

class Unidom::Order::Order < ActiveRecord::Base

  self.table_name = 'unidom_orders'

  validates :number,           presence: true, length:       { is: self.columns_hash['number'].limit  }
  validates :purchase_amount,  presence: true, numericality: { less_than: 1000000000, greater_than: 0 }
  validates :aggregate_amount, presence: true, numericality: { less_than: 1000000000, greater_than: 0 }

  belongs_to :placer, polymorphic: true
  belongs_to :taker,  polymorphic: true

  has_many :items,       class_name: 'Unidom::Order::OrderItem',       as: :order
  has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted

  scope :placed_by, ->(placer) { where placer: placer }
  scope :taken_by,  ->(taker)  { where taker:  taker  }

  include Unidom::Common::Concerns::ModelExtension

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-order-0.2 app/models/unidom/order/order.rb