Skip to content

hgmnz/fast_random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fast_random
==========

This plugin extends active record by adding a class level random method which returns a random record from the database.

The approach taken performs better than 'order by rand() limit 1' for large datasets. It uses offset instead of an order by to retrieve the random record in a database agnostic way.

Example
=======

class Foo < ActiveRecord::Base; end

Foo.random


Copyright (c) 2009 Harold A. Gimenez, released under the MIT license

About

Find a random record with ActiveRecord

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages