How to Get a Random ActiveRecord object

Simple add the following code to a new file:

# in config/initializers/active_record_random.rb

class ActiveRecord::Base
  def self.random
    self.limit(1).offset(rand(self.count)).first
  end
end