Sha256: 5a4fa76ae6802fc06a1b50f6af8d150b571029e4cdbf384e64440c7f351ef160

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Shoppe
  
  # The Shoppe::Country model stores countries which can be used for delivery & billing
  # addresses for orders.
  #
  # You can use the Shoppe::CountryImporter to import a pre-defined list of countries 
  # into your database. This automatically happens when you run the 'shoppe:setup' 
  # rake task.
  
  class Country < ActiveRecord::Base
    
    self.table_name = 'shoppe_countries'
    
    # All orders which have this country set as their billing country
    has_many :billed_orders, :dependent => :restrict_with_exception, :class_name => 'Shoppe::Order', :foreign_key => 'billing_country_id'
    
    # All orders which have this country set as their delivery country
    has_many :delivered_orders, :dependent => :restrict_with_exception, :class_name => 'Shoppe::Order', :foreign_key => 'delivery_country_id'
    
    # All countries ordered by their name asending
    scope :ordered, -> { order('shoppe_countries.name asc') }
    
    # Validations
    validates :name, :presence => true
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoppe-0.0.19 app/models/shoppe/country.rb
shoppe-0.0.18 app/models/shoppe/country.rb
shoppe-0.0.17 app/models/shoppe/country.rb