I’m trying to do an IN query, where I have an array of user objects
imaginatively named ‘users’:
:conditions=>[“user_id IN (?)”, users.collect{|u| u.id }.join(’,’)]
this ends up with:
… IN(‘1,2,3’) …
Obviously I want this to be:
… IN(1,2,3) …
or even
… IN(‘1’, ‘2’, ‘3’) …
How do I get ActiveRecord to stop quoting the whole thing?
I thought passing in the object array itself did the trick - the
documentation says as such, giving the following example:
Person.find(:all, :conditions => [ “category IN (?)”, categories])
When I try this, the array is printed and my query looks something like:
IN (’— !ruby/object:User \nattributes: …
Any ideas?
Thanks in advance - I’ll carry on Googling and see what I can turn up!