You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)))
The text was updated successfully, but these errors were encountered:
if I'm not mistaken, you need treatments_id_eq_ALL. but how it's possible to be (("treatments"."id" = 1 AND "treatments"."id" = 2)) ?!
may be treatments_id_in[] ?
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)))
The text was updated successfully, but these errors were encountered: