Method: ActiveRecord::Base.random
- Defined in:
- lib/common_lib/active_record/base.rb
.random ⇒ Object
def acts_like_a_hash(*args)
120 121 122 123 124 125 126 127 |
# File 'lib/common_lib/active_record/base.rb', line 120 def self.random count = count() if count > 0 offset(rand(count)).limit(1).first else nil end end |