Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Country Select Plugin

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.rdoc

CountrySelect

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.

Select helper example

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)

Using the country data

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

Something went wrong with that request. Please try again.