Sha256: 2779ab7e07bc8d73aeeb414aaee236bb0cb1c3817275cb3c977d30d4ed0b6f61

Contents?: true

Size: 1019 Bytes

Versions: 15

Compression:

Stored size: 1019 Bytes

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(:name => :asc) }
    
    # Validations
    validates :name, :presence => true
    
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
shoppe-1.1.1 app/models/shoppe/country.rb
shoppe-1.1.0 app/models/shoppe/country.rb
shoppe-1.0.9 app/models/shoppe/country.rb
shoppe-1.0.8 app/models/shoppe/country.rb
kylekthompson-shoppe-1.0.7 app/models/shoppe/country.rb
shoppe-1.0.7 app/models/shoppe/country.rb
shoppe-1.0.6 app/models/shoppe/country.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/shoppe-1.0.5/app/models/shoppe/country.rb
shoppe-1.0.5 app/models/shoppe/country.rb
shoppe-1.0.3 app/models/shoppe/country.rb
shoppe-1.0.2 app/models/shoppe/country.rb
shoppe-1.0.1 app/models/shoppe/country.rb
shoppe-1.0.0 app/models/shoppe/country.rb
shoppe-0.0.21 app/models/shoppe/country.rb
shoppe-0.0.20 app/models/shoppe/country.rb