Skip to content

Commit

Permalink
adding rails 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
onomojo committed Nov 16, 2013
1 parent daf937e commit 5abe3de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([email protected]) and Frank Wambutt ([email protected])

== 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
Expand Down
6 changes: 5 additions & 1 deletion lib/i18n_country_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 7 additions & 1 deletion lib/i18n_country_select/form_helpers.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/i18n_country_select/instance_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "<option>#{option}</option>\n"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n_country_select/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module I18nCountrySelect
VERSION = "1.0.19"
VERSION = "1.1.0"
end

0 comments on commit 5abe3de

Please sign in to comment.