lib/randumb/relation.rb
# If the max_items argument is omitted, one random entity will be returned.
# If you provide the integer argument, you will get back an array of records.
If the max_items argument is omitted, one random entity will be returned.
If you provide the integer argument, you will get back an array of records.
If the max_items argument is omitted one random entity will be returned . If you provide the integer argument you will get back an array of records .
def random(max_items = nil, opts={})
        ActiveSupport::Deprecation.warn "The random() method will be depricated in randumb 1.0 in favor of the order_by_rand scope."
        relation = clone
        return random_by_id_shuffle(max_items, opts) if is_randumb_postges_case?(relation)
        scope = relation.order_by_rand(opts)
        scope = scope.limit(max_items) if override_limit?(max_items, relation)
        max_items ? scope.to_a : scope.first
      end
def random ( max_items = nil , opts = { } ) ActiveSupport :: Deprecation . warn "The random() method will be depricated in randumb 1.0 in favor of the order_by_rand scope." relation = clone return random_by_id_shuffle ( max_items , opts ) if is_randumb_postges_case? ( relation ) scope = relation . order_by_rand ( opts ) scope = scope . limit ( max_items ) if override_limit? ( max_items , relation ) max_items ? scope . to_a : scope . first end
If the max_items argument is omitted, one random entity will be returned.
If the max_items argument is omitted one random entity will be returned .
# return first record if method was called without parameters
max_items
opts