Skip to content

Commit

Permalink
Fixed options being ignored when running Rails 4.
Browse files Browse the repository at this point in the history
A #delete call should've been #except.
Anyway, we can do it even better by reusing @options variable set by Rails 4's ActiveModelInstanceTag.
  • Loading branch information
leods92 committed Jul 9, 2014
1 parent 2e08939 commit 7f67355
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/i18n_country_select/form_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module FormHelpers
def country_code_select(object_name, method, priority_countries = nil, 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
instance_tag.to_country_code_select_tag(priority_countries, html_options)
else
instance_tag = ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object))
instance_tag.to_country_code_select_tag(priority_countries, html_options, options)
end
end
end
end
6 changes: 5 additions & 1 deletion lib/i18n_country_select/instance_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module I18nCountrySelect
module InstanceTag
include Countries

def to_country_code_select_tag(priority_countries, options = {}, html_options = {})
def to_country_code_select_tag(priority_countries, html_options = {}, options = {})
# Rails 4 stores options sent when creating an InstanceTag.
# Let's use them!
options = @options if defined?(@options)

country_code_select(priority_countries, options, html_options)
end

Expand Down

0 comments on commit 7f67355

Please sign in to comment.