Module: I18nCountrySelect::InstanceTag
- Includes:
- Countries
- Defined in:
- lib/i18n_country_select/instance_tag.rb
Constant Summary
Constants included from Countries
Instance Method Summary collapse
-
#country_code_select(priority_countries, options, html_options) ⇒ Object
Adapted from Rails country_select.
- #to_country_code_select_tag(priority_countries, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#country_code_select(priority_countries, options, html_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 25 26 27 28 29 30 |
# File 'lib/i18n_country_select/instance_tag.rb', line 10 def country_code_select(priority_countries, , ) selected = object.send(@method_name) country_translations = COUNTRY_CODES.map{|code| [I18n.t(code, :scope => :countries), code]} 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 + (country_translations, selected) = .stringify_keys add_default_name_and_id() content_tag(:select, countries.html_safe, ) end |
#to_country_code_select_tag(priority_countries, options = {}, html_options = {}) ⇒ Object
5 6 7 |
# File 'lib/i18n_country_select/instance_tag.rb', line 5 def to_country_code_select_tag(priority_countries, = {}, = {}) country_code_select(priority_countries, , ) end |