Class: Gaku::State

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gaku/state.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_all_by_name_or_abbr(name_or_abbr) ⇒ Object



10
11
12
# File 'app/models/gaku/state.rb', line 10

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

.states_group_by_country_isoObject

table of { country.id => [ state.id , state.name ] } arrays sorted by name blank is added elsewhere, if needed



17
18
19
20
21
22
23
# File 'app/models/gaku/state.rb', line 17

def self.states_group_by_country_iso
  state_info = Hash.new { |h, k| h[k] = [] }
  State.order('name ASC').each do |state|
    state_info[state.country_iso].push [state.id, state.name]
  end
  state_info
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
# File 'app/models/gaku/state.rb', line 25

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

#to_sObject



29
30
31
# File 'app/models/gaku/state.rb', line 29

def to_s
  name
end