Reputation: 5482
I have a product-model with a total of ~40 entries.
In one of my views I want to print all of these entries. I do that via something like
@products = Product.all
and in my view I iterate over the entries as so
@products.each do |p|
//Do some magic display
'Problem' now is that I further want to randomize what entry gets shown first. Is there any way to do this?
Thank you in advance.
Upvotes: 1
Views: 43
Reputation: 10111
you can try to do something like @products = Product.order("RANDOM()")
Upvotes: 1