No commit activity in last 3 years
No release in over 3 years
ActiveRecord Random is a Ruby Gem that empowers your ActiveRecord Models with the ability to return a random record without using SQL RAND().
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.0
~> 2.0
~> 2.0
~> 0.11.0

Runtime

~> 3.0.0
 Project Readme

This fork includes minor tweaks for the latest Rails 3.1 & Ruby 1.9

Introduction

ActiveRecord Random is a Ruby Gem that empowers your ActiveRecord Models with the ability to return a random record without using SQL RAND().

Compatibility

Developed to be compatible with

  • Rails: v3.0.x or v3.1.x
  • Ruby: v1.8.7, v1.9.1 or v1.9.2

Installation

You can install ActiveRecord Random straight from Rubygems. Thanks to Bundler you just need to add this to your Gemfile

  gem 'activerecord_random'

Examples

Scenario: You have a collection of Questions (model name = Question) and you wish to randomly select one of them.

  Question.random #=> random instance of Question

Alternatively you can use the :random finder:

  Question.find(:random) #=> random instance of Question

That simple

Documentation

This gem's documentation documentation is available at TODO

License

Copyright (c) 2010 Gnomeslab, Lda., released under the MIT license. For more information regarding MIT license, please check our MIT license file

Feedback, issues and contributions

If you have an issue with this Gem please create a ticket in our issue tracker.

Feel free to fork this project at any time and submit your changes (along with their respective tests).

Should you just wish to provide feedback or say hi, you can always contact us directly through diogo (dot) almeida (at) gnomeslab (dot) com