Class: Gaku::State
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gaku::State
- Defined in:
- app/models/gaku/state.rb
Class Method Summary collapse
- .find_all_by_name_or_abbr(name_or_abbr) ⇒ Object
-
.states_group_by_country_iso ⇒ Object
table of { country.id => [ state.id , state.name ] } arrays sorted by name blank is added elsewhere, if needed.
Instance Method Summary collapse
Class Method Details
.find_all_by_name_or_abbr(name_or_abbr) ⇒ Object
9 10 11 |
# File 'app/models/gaku/state.rb', line 9 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_iso ⇒ Object
table of { country.id => [ state.id , state.name ] } arrays sorted by name blank is added elsewhere, if needed
16 17 18 19 20 21 22 |
# File 'app/models/gaku/state.rb', line 16 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
24 25 26 |
# File 'app/models/gaku/state.rb', line 24 def <=>(other) name <=> other.name end |
#to_s ⇒ Object
28 29 30 |
# File 'app/models/gaku/state.rb', line 28 def to_s name end |