Browse files

Merge pull request #4 from jmazzi/master

Add Rails 3.2.2 compatibility
  • Loading branch information...
2 parents 38fe76e + 895bbd4 commit c2f7b70a97ba42a8ad234ae3f3330f5fca1fbe7e @jamesds committed Mar 2, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/country-select.rb
@@ -20,21 +20,23 @@ def country_options_for_select(selected = nil, priority_countries = nil)
country_options += options_for_select(priority_countries, selected)
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
# prevents selected from being included twice in the HTML which causes
# some browsers to select the second selected option (not priority)
# which makes it harder to select an alternative priority country
selected = nil if priority_countries.include?(selected)
+ country_options = country_options.html_safe if country_options.respond_to?(:html_safe)
return country_options + options_for_select(COUNTRIES, selected)
# All the countries included in the country_options output.
COUNTRIES = ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
"Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
"Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
- "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina",
+ "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina",
"Botswana", "Bouvet Island", "Brazil",
"British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia",
"Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
@@ -71,7 +73,7 @@ def country_options_for_select(selected = nil, priority_countries = nil)
"Venezuela, Bolivarian Republic of", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.",
"Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
class InstanceTag
def to_country_select_tag(priority_countries, options, html_options)
html_options = html_options.stringify_keys
@@ -85,7 +87,7 @@ def to_country_select_tag(priority_countries, options, html_options)
class FormBuilder
def country_select(method, priority_countries = nil, options = {}, html_options = {})
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)

0 comments on commit c2f7b70

Please sign in to comment.