diff --git a/README.rdoc b/README.rdoc index 5532678..7025a73 100644 --- a/README.rdoc +++ b/README.rdoc @@ -36,10 +36,12 @@ Supplying priority countries to be placed at the top of the list: * Marten Klitzke (https://github.com/mortik) * Victor D. (https://github.com/V1c70r) * Alexey Degtyarev (https://github.com/alexhifer) +* Björn Wilmsmann (https://github.com/BjoernKW) Based on the deprecated country_code_select by: Russ Smith (russ@bashme.org) and Frank Wambutt (frank@mo-stud.io) == Version History +* 1.1.0 - Rails 4 support * 1.0.19 - Added Macedonia * 1.0.18 - Fixed translated sorting * 1.0.17 - Removing duplicate country code IE diff --git a/lib/i18n_country_select.rb b/lib/i18n_country_select.rb index b06727e..2bb8414 100644 --- a/lib/i18n_country_select.rb +++ b/lib/i18n_country_select.rb @@ -8,5 +8,9 @@ require "i18n_country_select/instance_tag" ActionView::Base.send(:include, I18nCountrySelect::FormHelpers) -ActionView::Helpers::ActiveModelInstanceTag.send(:include, I18nCountrySelect::InstanceTag) +if Rails::VERSION::MAJOR >= 4 + ActionView::Helpers::ActiveModelInstanceTag.send(:include, I18nCountrySelect::InstanceTag) +else + ActionView::Helpers::InstanceTag.send(:include, I18nCountrySelect::InstanceTag) +end ActionView::Helpers::FormBuilder.send(:include, I18nCountrySelect::FormBuilder) diff --git a/lib/i18n_country_select/form_helpers.rb b/lib/i18n_country_select/form_helpers.rb index c987688..239b0cb 100644 --- a/lib/i18n_country_select/form_helpers.rb +++ b/lib/i18n_country_select/form_helpers.rb @@ -1,7 +1,13 @@ module I18nCountrySelect module FormHelpers def country_code_select(object_name, method, priority_countries = nil, options = {}, html_options = {}) - ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_country_code_select_tag(priority_countries, options, html_options) + if Rails::VERSION::MAJOR >= 4 + instance_tag = ActionView::Helpers::Tags::Select.new(object_name, method, self, [], options, html_options) + return instance_tag.to_country_code_select_tag(priority_countries, options.delete(:object), html_options) + else + instance_tag = ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)) + return instance_tag.to_country_code_select_tag(priority_countries, options, html_options) + end end end end diff --git a/lib/i18n_country_select/instance_tag.rb b/lib/i18n_country_select/instance_tag.rb index d970dc8..c4b26db 100644 --- a/lib/i18n_country_select/instance_tag.rb +++ b/lib/i18n_country_select/instance_tag.rb @@ -19,7 +19,7 @@ def country_code_select(priority_countries, options, html_options) countries = "" - if options[:include_blank] + if options.present? and options[:include_blank] option = options[:include_blank] == true ? "" : options[:include_blank] countries += "\n" end diff --git a/lib/i18n_country_select/version.rb b/lib/i18n_country_select/version.rb index 71dcbbe..34364ec 100644 --- a/lib/i18n_country_select/version.rb +++ b/lib/i18n_country_select/version.rb @@ -1,3 +1,3 @@ module I18nCountrySelect - VERSION = "1.0.19" + VERSION = "1.1.0" end