我正在使用Ransack gem,我需要有一个带有3个选项的select选项下拉列表,但每个选项都有多个值。我假设我需要使用* _in谓词,但是当我执行以下操作时:
**Service offering p-mysql not found**
并选择Pending Payroll或Denied,它只提取状态为0的对象。生成正确的(我认为)HTML:
<%= f.select :status_in, options_for_select([['Approved', 0], ['Pending Payroll', [1,3,5,7] ], ['Denied', [2,4,6,8] ]]), {include_blank: 'Any'}, {class: 'form-control input-sm'} %>
任何帮助将不胜感激!
答案 0 :(得分:0)
解决了有点绕着Ransack。我创建了一个简单的select_tag:
<%= select_tag :status_not_ransack, options_for_select(Request.select_options), {class: 'form-control input-sm'} %>
并在我的控制器中执行了以下操作:
if params[:status_not_ransack]
case params[:status_not_ransack]
when '0'
@q.status_in = [0]
when '1'
@q.status_in = [1,3,5,7]
when '2'
@q.status_in = [2,4,6,8]
else
@q.status_in = ''
end
end