Browse files

Call html_safe when needed (>= Rails 3.2.2)

This commit caused it to break
  • Loading branch information...
jmazzi committed Mar 1, 2012
1 parent 38fe76e commit 895bbd41c867a0fdce5e647834b6fb06e6fc1627
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 895bbd4

Please sign in to comment.