当前位置: 首页 > 工具软件 > SearchLogic > 使用案例 >

为SearchLogic添加一个remote_form_for方法。

弓举
2023-12-01
稍微看了一下,好像挺简单,只是处理了一下参数。
    # Automatically makes the form method :get if a Searchlogic::Search and sets
# the params scope to :search
def form_for(*args, &block)
if search_obj = args.find { |arg| arg.is_a?(Searchlogic::Search) }
options = args.extract_options!
options[:html] ||= {}
options[:html][:method] ||= :get
options[:url] ||= url_for
args.unshift(:search) if args.first == search_obj
args << options
end
super
end

#照抄着上面写了个remote_form_for
def remote_form_for(*args, &block)
if search_obj = args.find { |arg| arg.is_a?(Searchlogic::Search) }
options = args.extract_options!
options[:html] ||= {}
options[:method] ||= :get #改了一下这里就可以正常使用了。
options[:url] ||= url_for
args.unshift(:search) if args.first == search_obj
args << options
end
super
end
 类似资料: