Peter M. wrote:
Is it possible to use an array as a parameter value? I tried this and
got a mysql error, “Operand should contain 1 column(s)”.
class User < ActiveRecord::Base
location_ids = 
for location in self.locations
location_ids << location.id
Event.find(:all, :conditions => [“location_id = ?”, location_ids])
What you need is:
Event.find(:all, :conditions => [“location_id IN (?)”, location_ids])
It’s better to do it that way even if you are certain that the values
are coming from the database only. In this case it might be a bit
contrived because you are also pretty sure that it are integers only,
but generally unescaping may occur whilst reading from the database, and
you will want to be sure stuff is properly escaped and quoted again.
Roderick van Domburg