mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
22 lines
402 B
Ruby
22 lines
402 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class State < ActiveRecord::Base
|
|
belongs_to :country, class_name: 'Spree::Country'
|
|
|
|
validates :country, :name, presence: true
|
|
|
|
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
|