1

我正在尝试使用 meta_search 在同一控制器中的多个模型上运行搜索。使用我当前的代码,如果我为数据库输入一些内容,它可以工作,但是当我尝试应用程序时,我收到以下错误

 NoMethodError in HomeController#index

undefined method `stringify_keys!' for "test":String

app/controllers/home_controller.rb:6:in `index'

Parameters: 
{"utf8"=>"✓",
 "authenticity_token"=>"MFFR9GHZWSPBBFugTSvr7ZMJlxpWwGZqeNH3/SzPQ8k=",
 "q"=>"",
 "apps_name"=>"test",
 "commit"=>"Search"}

home_controller.rb

    class HomeController < ApplicationController
        def index
           @search = Database.search(params[:q])
           @databases = @search

           @search2 = Application.search(params[:apps_name])
           @application_s = @search2 
       end

       def about
       end    
  end

index.html.erb

<%= form_tag("/home/index", :method => "get") do %>
  <%= label_tag(:q, "Database:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

<%= form_tag("/home/index", :method => "get") do %>
  <%= label_tag(:app_name, "Application:") %>
  <%= text_field_tag(:app_name) %>
  <%= submit_tag("Search") %>
<% end %>
4

0 回答 0