Help with sorting / ordering

easiest and fastest way is to keep number of reviews in column in product table... then simple add :order => 'reviews_count desc' in your Product.find()

tom

Robert Scott wrote:

and don't forget to add to reviews model:
belongs_to :product, :counter_cache => true

OK. so then you need to create your own queries with Reviews.find_by_sql() and insert appropriate sql statement, eg

select product_id, count(*) as counter from reviews where age between (10,20) and ... order by 2 desc

tom

Robert Scott wrote: