vendredi 24 juin 2016

Efficient way to randomize data model in Rails

Creating a programming schedule based on videos in object model. I want to run a task every day to shuffle this model so the programming each day would be different.

I am aware of product.shuffle.all for ex. but I want the order to be saved one time each day to do so vs on each server call.

I am thinking to add an attribute to each product, named order which would be an integer to order by. How would I shuffle just product.order for all products in this case?

Would this be the most efficient way? Thanks for the help!




Aucun commentaire:

Enregistrer un commentaire