Sha256: 172af6bf26f9045449d02e3fb482da94f811e2bc5e7acb63c39dc03bff503317

Contents?: true

Size: 508 Bytes

Versions: 26

Compression:

Stored size: 508 Bytes

Contents

module Spree
  class Country < ActiveRecord::Base
    has_many :states, -> { order('name ASC') }, dependent: :destroy
    has_many :addresses, dependent: :nullify

    validates :name, :iso_name, presence: true

    def self.states_required_by_country_id
      states_required = Hash.new(true)
      all.each { |country| states_required[country.id.to_s]= country.states_required }
      states_required
    end

    def <=>(other)
      name <=> other.name
    end

    def to_s
      name
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
spree_core-2.2.14 app/models/spree/country.rb
spree_core-2.2.13 app/models/spree/country.rb
spree_core-2.2.12 app/models/spree/country.rb
spree_core-2.2.11 app/models/spree/country.rb
spree_core-2.2.10 app/models/spree/country.rb
spree_core-2.2.9 app/models/spree/country.rb
spree_core-2.1.12 app/models/spree/country.rb
spree_core-2.2.8 app/models/spree/country.rb
spree_core-2.1.11 app/models/spree/country.rb
spree_core-2.2.7 app/models/spree/country.rb
spree_core-2.1.10 app/models/spree/country.rb
spree_core-2.1.9 app/models/spree/country.rb
spree_core-2.2.6 app/models/spree/country.rb
spree_core-2.2.5 app/models/spree/country.rb
spree_core-2.1.8 app/models/spree/country.rb
spree_core-2.2.4 app/models/spree/country.rb
spree_core-2.2.3 app/models/spree/country.rb
spree_core-2.2.2 app/models/spree/country.rb
spree_core-2.1.7 app/models/spree/country.rb
spree_core-2.1.6 app/models/spree/country.rb