Ruby on rails 未定义的方法'stringify\u keys';至于;测试“:字符串元搜索在一个操作中进行多个搜索
我正在尝试使用meta_搜索在同一控制器中的多个模型上运行搜索。使用我当前的代码,如果我为数据库输入了一些东西,它就会工作,但当我尝试应用程序时,会出现以下错误Ruby on rails 未定义的方法'stringify\u keys';至于;测试“:字符串元搜索在一个操作中进行多个搜索,ruby-on-rails,search,meta-search,Ruby On Rails,Search,Meta Search,我正在尝试使用meta_搜索在同一控制器中的多个模型上运行搜索。使用我当前的代码,如果我为数据库输入了一些东西,它就会工作,但当我尝试应用程序时,会出现以下错误 NoMethodError in HomeController#index undefined method `stringify_keys!' for "test":String app/controllers/home_controller.rb:6:in `index' Parameters: {"utf8"=>"
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
class HomeController
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 %>
“get”)do%>
“get”)do%>
跟踪表明错误在控制器的第9行,在索引操作下。但是手动计算行数让我相信您删除了操作中的一些代码。如果删除了任何代码,是否可以使用完整的索引操作更新问题?调用的“搜索”方法接受哪些参数?他们似乎希望使用哈希,而不是传递字符串。jvnill-->我已更新了控制器。grotori-->我是rails新手,但我相信meta_search的搜索函数接受字符串数组作为参数。