Class: Spree::State
- Defined in:
- app/models/spree/state.rb
Class Method Summary collapse
- .find_all_by_name_or_abbr(name_or_abbr) ⇒ Object
-
.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
belongs_to_required_by_default, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope
Methods included from Preferences::Preferable
#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference
Class Method Details
.find_all_by_name_or_abbr(name_or_abbr) ⇒ Object
19 20 21 |
# File 'app/models/spree/state.rb', line 19 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_id ⇒ Object
table of { country.id => [ state.id , state.name ] }, arrays sorted by name blank is added elsewhere, if needed
25 26 27 28 29 30 31 |
# File 'app/models/spree/state.rb', line 25 def self.states_group_by_country_id state_info = Hash.new { |h, k| h[k] = [] } order(:name).each do |state| state_info[state.country_id.to_s].push [state.id, state.name] end state_info end |
Instance Method Details
#<=>(other) ⇒ Object
33 34 35 |
# File 'app/models/spree/state.rb', line 33 def <=>(other) name <=> other.name end |
#to_s ⇒ Object
37 38 39 |
# File 'app/models/spree/state.rb', line 37 def to_s name end |