Module: RandomOrder::Extension
- Included in:
- Railtie
- Defined in:
- lib/random_order/random_order/extension.rb
Instance Method Summary collapse
Instance Method Details
#fast_random(n = 1) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/random_order/random_order/extension.rb', line 15 def fast_random(n = 1) if self.primary_key.present? RandomOrder.sql_query_string(self, n) else random.limit(n) end end |
#find_many_random(n) ⇒ Object
3 4 5 |
# File 'lib/random_order/random_order/extension.rb', line 3 def find_many_random(n) random.limit(n) end |
#find_random ⇒ Object
7 8 9 |
# File 'lib/random_order/random_order/extension.rb', line 7 def find_random random.first end |
#random ⇒ Object
11 12 13 |
# File 'lib/random_order/random_order/extension.rb', line 11 def random self.order(RandomOrder.order_func) end |