Get random collection of records with Active Record
28 April 2022 (Updated 28 April 2022)
Suppose you have a Reminder
model and you want to return x
number of records at random. Something like this:
Here’s how:
This will produce two SQL queries. Something like:
Tagged:
Rails
Thanks for your comment . Once it's approved, it will appear here.
Leave a comment