Sha256: 7982cd7eaaafe5da1fc5a9b8b71ebb27b7d9c922df455040a540c130bd02a238

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 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

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-1.1.2 app/models/shoppe/country.rb