countries 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/countries.gemspec +1 -1
- data/lib/countries/select_helper.rb +10 -3
- data/lib/countries/version.rb +1 -1
- metadata +2 -2
data/countries.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require File.expand_path('../lib/countries/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["
|
5
|
+
gem.authors = ["Josh Robinson", "Joe Corcoran"]
|
6
6
|
gem.email = ["hexorx@gmail.com"]
|
7
7
|
gem.description = %q{All sorts of useful information about every country packaged as pretty little country objects. It includes data from ISO 3166}
|
8
8
|
gem.summary = %q{Gives you a country object full of all sorts of useful information.}
|
@@ -8,14 +8,21 @@ module ActionView
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def country_options_for_select(selected = nil, priority_countries = nil)
|
11
|
-
country_options = ""
|
11
|
+
country_options = ""
|
12
12
|
|
13
13
|
if priority_countries
|
14
|
-
priority_countries = [*priority_countries].map {|x| [x
|
14
|
+
priority_countries = [*priority_countries].map {|x| [x,ISO3166::Country::NameIndex[x]] }
|
15
15
|
country_options += options_for_select(priority_countries, selected)
|
16
|
-
country_options +=
|
16
|
+
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
17
|
+
|
18
|
+
# prevent selected from being included twice in the HTML which causes
|
19
|
+
# some browsers to select the second selected option (not priority)
|
20
|
+
# which makes it harder to select an alternative priority country
|
21
|
+
selected = nil if priority_countries.include?([ISO3166::Country[selected].name, selected])
|
17
22
|
end
|
18
23
|
|
24
|
+
country_options = country_options.html_safe if country_options.respond_to?(:html_safe)
|
25
|
+
|
19
26
|
countries = ISO3166::Country::Names.map{|(name,alpha2)| [name.html_safe,alpha2] }
|
20
27
|
|
21
28
|
return country_options + options_for_select(countries, selected)
|
data/lib/countries/version.rb
CHANGED
metadata
CHANGED