using an arrray as a parameter value in ActiveRecord

If you are certain the values are save (as in your example), I have used this many times:

in = "("+self.locations.collect{|loc| loc.id}.join(',')+")" Event.find(:all, :conditions => "location_id in #{in}")

As I said before, make sure you know the values are safe or there is an obvious sql injection, but for id's coming from your database, this should work well.

Peter Marks wrote:

make that “values are safe”…I need to go to bed :slight_smile:

William Pratt wrote: