Update: This answer is more relevant for Rails 4.x
Do this:
current_user.comments.where(:id=>[123,"456","Michael Jackson"])
The stronger side of this approach is that it returns a Relation
object, to which you can join more .where
clauses, .limit
clauses, etc., which is very helpful. It also allows non-existent IDs without throwing exceptions.
The newer Ruby syntax would be:
current_user.comments.where(id: [123, "456", "Michael Jackson"])