Method on a array of objects from the database

Pierre Valade
Thu, 29 Nov 2007 19:23:49 -0000

Hello,

I would like to know the more elegant way to add a method for an array
of objects from the database.

Let me give an example :

Class Product
 ....
end

And in my controller :

@products = Product.find(:all)

And now I want to define a method which I could like

@products.select_fruits

having said somewhere :

def select_fruits
 ....
end

Thank you very much,