Getting results matching with an array?

I have an array authors=[1,3,7] and I want to get all the posts that match with any or all of these results. something like...

posts = Post.find(:all, [:conditions => ''author_id = ?', authors])

of course this wont work but I need something like it that works..

thanks

Vapor .. wrote:

I have an array authors=[1,3,7] and I want to get all the posts that match with any or all of these results. something like...

posts = Post.find(:all, [:conditions => ''author_id = ?', authors])

of course this wont work but I need something like it that works..

thanks

Simply use

posts = Post.find(:all, :conditions => ['author_id IN (?)', authors])

Vapor .. wrote:

I have an array authors=[1,3,7] and I want to get all the posts that match with any or all of these results. something like...

posts = Post.find(:all, [:conditions => ''author_id = ?', authors])

of course this wont work but I need something like it that works..

You can also use Post.find(authors), as it accepts an array. That
fires off SQL identical to what Wouter posted.

Doug