Sha256: 058276e06eaf3b74e891c67c7de7a84e844eb8f9fbb5eaf10c32a099b0a66d2c

Contents?: true

Size: 466 Bytes

Versions: 2

Compression:

Stored size: 466 Bytes

Contents

module Spree
  class State < ActiveRecord::Base
    belongs_to :country

    has_one :zone_member, :as => :zoneable
    has_one :zone, :through => :zone_member

    validates :country, :name, :presence => true

    attr_accessible :name, :abbr

    def self.find_all_by_name_or_abbr(name_or_abbr)
      where("name = ? OR abbr = ?", name_or_abbr, name_or_abbr)
    end

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

    def to_s
      name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-1.0.7 app/models/spree/state.rb
spree_core-1.0.6 app/models/spree/state.rb