collectiveidea / random_finders
random_finders
PublicA Rails plugin that allows quick and easy fetching of random records, or records in random order.
11 filesupdated Jun 18, 2026
files7Download
./libJun 14, 2026./tasksJun 14, 2026./testJun 14, 2026init.rbJun 14, 2026MIT-LICENSEJun 14, 2026RakefileJun 14, 2026READMEJun 18, 2026README
RandomFinders
Allows quick and easy fetching of random records, or records in random order.
Simply pass the :random to the order in any finder method.
Examples
Find a random article Article.find(:first, :order => :random)
Randomize photos Photo.find(:all, :order => :random)
Caveat
This will not treat you nicely with large datasets.
Read about it here: http://daniel.collectiveidea.com/blog/tags/random_finders
Based on an idea by Mike Burns http://mikeburnscoder.wordpress.com/2006/08/18/retrieving-random-elements-from-an-activerecord/
Copyright (c) 2007 Daniel Morrison, Collective Idea (http://collectiveidea.com), released under the MIT license