No commit activity in last 3 years
No release in over 3 years
Provides a simple helper to get an HTML select list of countries translate in german. 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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Rails – Country Select German

Build Status

Provides a simple helper to get an HTML select list of countries using the ISO 3166-1 standard.

It is also configurable to use countries' ISO 3166-1 alpha-2 codes as values and ISO 3166-1 names as display strings.

While the ISO 3166 standard is a relatively neutral source of country names, it may still offend some users. Developers are strongly advised to evaluate the suitability of this list given their user base.

Installation

Install as a gem using

gem install country_select_german

Or put the following in your Gemfile

gem 'country_select_german'

Example

Simple use supplying model and attribute as parameters:

country_select("user", "country")

Supplying priority countries to be placed at the top of the list:

country_select("user", "country", [ "Great Britain", "France", "Germany" ])

Using ISO 3166-1 alpha-2 codes as values

You can have the option tags use ISO 3166-1 alpha-2 codes as values and the country names as display strings. For example, the United States would appear as <option value="us">United States</option>

If you're starting a new project, this is the recommended way to store your country data since it will be more resistant to country names changing.

country_select("user", "country_code", nil, iso_codes: true)
country_select("user", "country_code", [ "gb", "fr", "de" ], iso_codes: true)

Getting the Country from ISO codes

class User < ActiveRecord::Base

  # Assuming country_select is used with User attribute `country_code`
  def country_name
    ::CountrySelect::COUNTRIES[country_code]
  end

end

Tests

bundle
bundle exec rspec

Running with multiple versions of actionpack

bundle exec appraisal

Copyright (c) 2008 Michael Koziarski, released under the MIT license