Module: Randumb::ActiveRecord::Base
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/randumb/relation.rb
Overview
Class methods where(nil) is because: stackoverflow.com/questions/18198963/with-rails-4-model-scoped-is-deprecated-but-model-all-cant-replace-it
Instance Method Summary collapse
- #order_by_rand(opts = {}) ⇒ Object
- #order_by_rand_weighted(ranking_column, opts = {}) ⇒ Object
- #random(max_items = nil, opts = {}) ⇒ Object
- #random_by_id_shuffle(max_items = nil, opts = {}) ⇒ Object
- #random_weighted(ranking_column, max_items = nil, opts = {}) ⇒ Object
Instance Method Details
#order_by_rand(opts = {}) ⇒ Object
180 181 182 |
# File 'lib/randumb/relation.rb', line 180 def order_by_rand(opts = {}) where(nil).order_by_rand(opts) end |
#order_by_rand_weighted(ranking_column, opts = {}) ⇒ Object
184 185 186 |
# File 'lib/randumb/relation.rb', line 184 def order_by_rand_weighted(ranking_column, opts={}) where(nil).order_by_rand_weighted(ranking_column, opts) end |
#random(max_items = nil, opts = {}) ⇒ Object
168 169 170 |
# File 'lib/randumb/relation.rb', line 168 def random(max_items = nil, opts = {}) where(nil).random(max_items, opts) end |
#random_by_id_shuffle(max_items = nil, opts = {}) ⇒ Object
176 177 178 |
# File 'lib/randumb/relation.rb', line 176 def random_by_id_shuffle(max_items = nil, opts = {}) where(nil).random_by_id_shuffle(max_items, opts) end |
#random_weighted(ranking_column, max_items = nil, opts = {}) ⇒ Object
172 173 174 |
# File 'lib/randumb/relation.rb', line 172 def random_weighted(ranking_column, max_items = nil, opts = {}) where(nil).random_weighted(ranking_column, max_items, opts) end |