ernie/ransack — Issue #53: ransack and checkboxes
Author: suciuvlad
Created: 2011-12-24 13:39:56+00:00
State: open

model CLINIC has many TREATMENTS

I'm doing an advanced search on the clinics to filter them. I have this in my form:
<%= check_box_tag "q[treatments_id_eq][]", treatment.id, {} %>

Basically, i'm trying to send an array of the selected treatments to the search. I get the following error:
undefined method `to_i' for ["1", "2"]:Array

Using treatments_id_eq_ANY works and this is the generated query:
SELECT DISTINCT "clinics".* FROM "clinics" LEFT OUTER JOIN "countries" ON "countries"."id" = "clinics"."country_id" LEFT OUTER JOIN "clinics_treatments" ON "clinics_treatments"."clinic_id" = "clinics"."id" LEFT OUTER JOIN "treatments" ON "treatments"."id" = "clinics_treatments"."treatment_id" WHERE (("treatments"."id" = 1 OR "treatments"."id" = 2))

However I want to have them connected by AND instead of OR (WHERE (("treatments"."id" = 1 OR "treatments"."id" = 2)))