问题描述
我有一个简单的搜索表:
<%= form_with(url: recherche_path,method: "get",class: "side-box",local: true) do %>
<div id="search-container">
<%= text_field_tag(:q,nil,placeholder: "Rechercher un mot dans le dictionnaire...",id: "search") %>
<ul id="search-results"></ul>
</div>
<% end %>
它重定向到此控制器方法:
def recherche
@results = Word.search(params['q']).first(20)
end
使用此模型范围:
scope :search,->(content) {
quoted_content = ActiveRecord::Base.connection.quote_string(content)
where("content % :content",content: content).
order(Arel.sql("similarity(content,'#{quoted_content}') DESC"))
}
在开发中一切正常,但在生产中出现以下错误:
没有将nil隐式转换为String
似乎params [:q]返回nil,但是我找不到原因?
编辑
这是呈现的HTML表单(在操作here中查看):
<form class="side-box" action="/dictionnaire/recherche" accept-charset="UTF-8" data-remote="true" method="get">
<div id="search-container" data-children-count="1">
<input type="text" name="q" id="search" placeholder="Rechercher un mot dans le dictionnaire..." class="">
<ul id="search-results"></ul>
</div>
</form>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)