Skip to content

gunn/country_select

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provides a simple helper to get an HTML select list of countries. The list of countries comes from the ISO 3166 standard. While it is a relatively neutral source of country names, it will still offend some users.

Users are strongly advised to evaluate the suitability of this list given their user base.

To output a drop-down menu of all countries, with Australia and New Zealand at the top:

country_select(:user, :country, ["AU", "NZ"], :prompt => true, :value => user.country)

This version supports saving the country abbreviation in the database, and has abstracted the list of countries out into a Geography module. This way, you can use this list in your models:

class Address < ActiveRecord::Base
  validates_inclusion_of :country_code, :in => Geography::country_codes

  def country_name
    Geography::country_name_from_code( country_code )
  end
end

Code by Michael Koziarski, Jim Benton, Arthur Gunn.

Released under the MIT license

About

Country Select Plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%