我需要使用Ransack,我安装了gem,我重新启动我的服务器,我在我的控制器中写道:
def index
@q = Sound.search(params[:q])
@sounds = @q.result
end
在我看来:
<%= search_form_for @query do |f| %>
<%= f.label :title_cont %>
<%= f.text_field :title_cont %>
<%= f.submit "Search" %>
<% end %>
但我有一个错误:
ActiveRecord::Relation:0x007fa185e9c2c0〉的未定义方法`result'
我试图找到答案,但一切都不起作用。
谢谢你的帮助
编辑:我找到了我的解决方案,我使用另一个宝石:太阳黑子和工作。
谢谢大家的帮助。
1条答案
按热度按时间htrmnn0y1#
我刚刚遇到了同样的问题。
我在这里找到了解决方案https://github.com/activerecord-hackery/ransack/issues/266
我变了
到
我认为ActiveAdmin已经覆盖了我的搜索方法,所以,正如上面的链接所解释的那样,ransack方法已经被创建来运行搜索,以防另一个gem使用了“search”。