The first question is, if you do not need all the records, then why even return them from the database? Why not use the where clause to filter the results:
@products = Product.where(<CONDITIONS>)
Secondly, if you insist on returning all the results and then filtering, use the .reject block:
@products = Product.all.reject { |p| <CONDITION> }
tagCincy
source share