lundi 28 mars 2016

Sqlite query change random number every minute

ROR Active Record, there is Sqlite query, which is returning rows ordered by random number. Is it possible to change the random number one time per minute? So the query result is the same during 60 seconds (assuming that database is not modified).

@topics = Topic.order('id + abs(random()%101) DESC').limit(10)




Aucun commentaire:

Enregistrer un commentaire