I'm using the Ransack gem, and am needing to have a select option dropdown with 3 options, but each option having multiple values. I would assume I would need to use the *_in predicate but when I do the following:
<%= 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'} %>
and select Pending Payroll or Denied, it only fetches objects with statuses of 0. The correct (I think) HTML is generated:
<option value="0">Approved</option>
<option value="[1, 3, 5, 7]">Pending Payroll</option>
<option value="[2, 4, 6, 8]">Denied</option>
Any assistance would be appreciated!
Solved by somewhat going around Ransack. I created a simple select_tag:
<%= select_tag :status_not_ransack, options_for_select(Request.select_options), {class: 'form-control input-sm'} %>
and just did the following in my controller:
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