Module: CountryCodeSelect::InstanceTag
- Includes:
- Countries
- Defined in:
- lib/country_code_select/instance_tag.rb
Constant Summary
Constants included from Countries
Instance Method Summary collapse
-
#country_code_select(priority_countries, options) ⇒ Object
Adapted from Rails country_select.
- #to_country_code_select_tag(priority_countries, options = {}) ⇒ Object
Instance Method Details
#country_code_select(priority_countries, options) ⇒ Object
Adapted from Rails country_select. Just uses country codes instead of full names.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/country_code_select/instance_tag.rb', line 10 def country_code_select(priority_countries, ) selected = object.send(@method_name) countries = "" if priority_countries countries += (priority_countries, selected) countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" elsif [:include_blank] countries += "<option value=\"\">" + [:include_blank] + "</options>\n" countries += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" end countries = countries + (COUNTRIES, selected) content_tag(:select, countries, .merge(id: "#{@object_name}_#{@method_name}", :name => "#{@object_name}[#{@method_name}]"), false) end |
#to_country_code_select_tag(priority_countries, options = {}) ⇒ Object
5 6 7 |
# File 'lib/country_code_select/instance_tag.rb', line 5 def to_country_code_select_tag(priority_countries, = {}) country_code_select(priority_countries, ) end |