Listing Model - belongs_to :area
Area Model - has_many :listings
我正在尝试使用带有复选框的 Ransack 实现搜索;在用户检查选定区域的地方,搜索返回选定区域的所有列表。
<%= search_form_for @search do |f| %>
<% areas = Area.all %>
<% areas.each do |area| %>
<%= check_box_tag('q[area_id_eq][]', area.id) %>
<%= area.location%>
<% end%>
<%= f.submit "SEARCH" %>
<% end %>
控制台输出:
Parameters: {"utf8"=>"✓", "q"=>{"area_id_eq"=>["1", "2"]}, "commit"=>"SEARCH"}
Completed 500 Internal Server Error in 4ms
NoMethodError - undefined method `to_i' for ["1", "2"]:Array:
只是不确定如何实现它以接受多个复选框值。