Module: SubdivisionSelect::SubdivisionsHelper
- Defined in:
- app/helpers/subdivision_select/subdivisions_helper.rb
Class Method Summary collapse
Class Method Details
.get_subdivisions(alpha2) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/subdivision_select/subdivisions_helper.rb', line 3 def self.get_subdivisions(alpha2) # The countries gem returns a hash, where: # the keys are the ISO 3166-2 subdivision two letter codes # and the value is a hash with two key/values: # - "name" is the most popular/most correct name # - "names" is an array of all the names if Country[alpha2].nil? {} else Country[alpha2].subdivisions.map { |k, v| [k, v["name"]] }.to_h end end |
.get_subdivisions_for_select(alpha2) ⇒ Object
16 17 18 |
# File 'app/helpers/subdivision_select/subdivisions_helper.rb', line 16 def self.get_subdivisions_for_select(alpha2) get_subdivisions(alpha2).invert.to_a end |