Last active
December 14, 2015 12:09
-
-
Save derekrockwell/5084561 to your computer and use it in GitHub Desktop.
MetaSearch update for ActionPack 4.0 to support. Unsure if this has any functionality effects and it is untested, use with caution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MetaSearch | |
module Helpers | |
module FormHelper | |
def apply_form_for_options!(record,object,options) | |
if object.is_a?(MetaSearch::Builder) | |
builder = object | |
options[:url] ||= polymorphic_path(object.base) | |
elsif object.is_a?(Array) && (builder = object.detect {|o| o.is_a?(MetaSearch::Builder)}) | |
options[:url] ||= polymorphic_path(object.map {|o| o.is_a?(MetaSearch::Builder) ? o.base : o}) | |
else | |
super | |
return | |
end | |
html_options = { | |
:class => options[:as] ? "#{options[:as]}_search" : "#{builder.base.to_s.underscore}_search", | |
:id => options[:as] ? "#{options[:as]}_search" : "#{builder.base.to_s.underscore}_search", | |
:method => :get } | |
options[:html] ||= {} | |
options[:html].reverse_merge!(html_options) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment