Rails plugin to pick random items from a model (without using :order => "RAND()")
License
porras/random_items
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
*random_items* is a Rails plugin which allows to pick random items from an ActiveRecord model (without using <tt>:order => "RAND()"</tt> which is not a good idea in terms of performance). The interface is almost the same as that of <tt>ActiveRecord::Base.find</tt>. Some examples: Picking a random item: Model.random(:first) Picking 5 random items: Model.random(:all, :limit => 5) Pickings a random item using standard <tt>ActiveRecord::Base.find</tt> options, such as <tt>:include</tt> Model.random(:first, :include => :relation) In that last case, you are expected not to use options which don't make sense, such as <tt>:order</tt> =;-) Copyright (c) 2008 Sergio Gil, released under the MIT license
About
Rails plugin to pick random items from a model (without using :order => "RAND()")
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published