Paginated Random Order

I'm trying to figure out how to create a region that will return random ActiveRecords, and will_paginate also supports.

Currently, each page view gets a completely different random set of ActiveRecords. Thus, each pagination link is actually just another random set of records.

How can I set up a region to be a random order that is saved through pagination?

I guess I need to have some kind of seed based on time?

+3
source share
1 answer

, ORDER BY RAND() SQL, . , :

RAND(), RAND(N)

[...] N, , .

, (, seed = rand(1e6) - Ruby) . , , MySQL RAND.

, ORDER BY RAND() ( ) . , , (, RAND) , . , : , 11 /, 23. , ( ) ( ), . RAND , , - .

+2

All Articles