Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails4 compatibility #20

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/carmen/rails/action_view/form_helper.rb
Expand Up @@ -83,6 +83,7 @@ def region_options_for_select(regions, selected=nil, options={})
options.stringify_keys!
priority_region_codes = options['priority'] || []
region_options = ""
region_options += options_for_select [[options['prompt'], '']] if options['prompt']

unless priority_region_codes.empty?
unless regions.respond_to?(:coded)
Expand All @@ -101,7 +102,6 @@ def region_options_for_select(regions, selected=nil, options={})

main_options = regions.map { |r| [r.name, r.code] }
main_options.sort!{|a, b| a.first.to_s <=> b.first.to_s}
main_options.unshift [options['prompt'], ''] if options['prompt']

region_options += options_for_select(main_options, selected)
region_options.html_safe
Expand All @@ -124,8 +124,8 @@ def region_options_for_select(regions, selected=nil, options={})
# country_select_tag('country_code', {priority: ['US', 'CA']}, class: 'region')
#
# Returns an `html_safe` string containing the HTML for a select element.
def country_select_tag(name, value, options={})
subregion_select_tag(name, value, Carmen::World.instance, options)
def country_select_tag(name, value, options={}, html_options={})
subregion_select_tag(name, value, Carmen::World.instance, options, html_options)
end

# Generate select and subregion option tags for the given object and method. A
Expand Down Expand Up @@ -172,6 +172,11 @@ def determine_parent(parent_region_or_code)
end
end

if Rails.version.to_s > '4'
class InstanceTag < ActionView::Helpers::Tags::Base
end
end

class InstanceTag
def to_region_select_tag(parent_region, options = {}, html_options = {})
html_options = html_options.stringify_keys
Expand Down