Sha256: 12502a96b6f7323ef300788d064c90e8567a0ff9fcdffcefa02a6a653a2d5283

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kkt_shoppe-2.0.2 app/models/kkt_shoppe/country.rb
kkt_shoppe-2.0.1 app/models/kkt_shoppe/country.rb
kkt_shoppe-2.0.0 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.3.0 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.2.1 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.2.0 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.1.2 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.1.1 app/models/kkt_shoppe/country.rb
kkt_shoppe-1.1.0 app/models/kkt_shoppe/country.rb