I've got a named scope like this:
named_scope :by_items, lambda |*items| {
:joins => :items,
:conditions => ["items.id in (?)", items.map(&::id)]
}
What's the "*item" mean? When I call it with "Item.find(:first, ...)" it works fine. If I try to call using a collection, "Item.find(:all, ...)" it fails.
From a different SO question, I know the signature is supposed to be:
Order.by_items(item0, item1, ...)
So, my question really is, how do I turn an Array into a comma separated argument list?
UPDATE0
From Martin Fowler I've learned:
(Using a "*" in the argument list helps in working with variable arguments in ruby. In the argument list disks indicates a vararg. I can then refer to all the disks passed in as an array named "disks". If I call another function with "disks" the elements of the disks array are passed in as separate arguments.)
UPDATE1
More on the "splat" operator.