新手问题 问个关于 ransack 的简单问题

shoushen · June 24, 2017 · 1052 hits

我想用 ransack 做一个 cont_all 的搜索,是不是要先分割成数组,感觉不够优雅啊。

以下是代码:

视图:

<%= search_form_for @q do |f| %>
    <%= f.search_field :title_cont_all %>
    <%= f.submit "搜索"  %>
<% end %>

控制器:

@q = List.ransack( title_cont_all: params[:q][:title_cont_all].split )   #要这么写吗?
@lists = @q.result(distinct: true)
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.