Sha256: 112b088b8b89c742b59d105ba2196d91c7cb6771d7797cb2f28be92a7f4efefd
Contents?: true
Size: 613 Bytes
Versions: 3
Compression:
Stored size: 613 Bytes
Contents
module SubdivisionSelect module SubdivisionsHelper 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 def self.get_subdivisions_for_select(alpha2) get_subdivisions(alpha2).invert.to_a end end end
Version data entries
3 entries across 3 versions & 1 rubygems