Get random records in Rails 06 Feb 2023 rails activerecord MySQL User.order("RAND()").limit(10) PostgreSQL User.order("RANDOM()").limit(10) Ruby Array#sample User.where(id: User.ids.sample(10)) Reference What’s the ‘Rails 4 Way’ of finding some number of random records? - Stack Overflow Load more