Plugins - Random Finders

StarAdd to favorites

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 © 2007 Daniel Morrison, Collective Idea (http://collectiveidea.com), released under the MIT license

Daniel Morrison, Collective Idea

http://daniel.collectiveidea.com/blog/tags/random_finders

http://source.collectiveidea.com/public/rails/plugins/random_finders/

Rails' (MIT)

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Searching and Queries

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?