Skip to content

Instantly share code, notes, and snippets.

@derekrockwell
Last active December 14, 2015 12:09
Show Gist options
  • Save derekrockwell/5084561 to your computer and use it in GitHub Desktop.
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.
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