Class: Spree::State
- Defined in:
- app/models/spree/state.rb
Class Method Summary collapse
-
.states_group_by_country_id ⇒ Object
table of { country.id => [ state.id , state.name ] }, arrays sorted by name blank is added elsewhere, if needed.
Instance Method Summary collapse
Methods inherited from Base
display_includes, #initialize_preference_defaults, page, preference
Methods included from Preferences::Preferable
#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.states_group_by_country_id ⇒ Object
table of { country.id => [ state.id , state.name ] }, arrays sorted by name blank is added elsewhere, if needed
24 25 26 27 28 29 30 |
# File 'app/models/spree/state.rb', line 24 def self.states_group_by_country_id state_info = Hash.new { |h, k| h[k] = [] } order(:name).each { |state| state_info[state.country_id.to_s].push [state.id, state.name] } state_info end |
Instance Method Details
#<=>(other) ⇒ Object
32 33 34 |
# File 'app/models/spree/state.rb', line 32 def <=>(other) name <=> other.name end |
#to_s ⇒ Object
36 37 38 |
# File 'app/models/spree/state.rb', line 36 def to_s name end |