Sha256: 5f6a617630f2b9a5ea62ad7c992a63abae2cd4dfcf50f312602747e3b5f6aed0

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

class Shoppe::DeliveryServicePrice < ActiveRecord::Base

  # Set the table name
  self.table_name = 'shoppe_delivery_service_prices'
  
  # Relationships
  belongs_to :delivery_service, :class_name => 'Shoppe::DeliveryService'
  belongs_to :tax_rate, :class_name => "Shoppe::TaxRate"
  
  # Validations
  validates :price, :numericality => true
  validates :cost_price, :numericality => true, :allow_blank => true
  validates :min_weight, :numericality => true
  validates :max_weight, :numericality => true
  
  # Scopes
  scope :ordered, -> { order('price asc')}
  scope :for_weight, -> weight { where("min_weight <= ? AND max_weight >= ?", weight, weight) }
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-0.0.11 app/models/shoppe/delivery_service_price.rb