lib/randumb/relation.rb
def random_weighted(ranking_column, max_items = nil, opts={})
        ActiveSupport::Deprecation.warn "The random_weighted() method will be depricated in randumb 1.0 in favor of the order_by_rand_weighted scope."
        relation = clone
        return random_by_id_shuffle(max_items, opts) if is_randumb_postges_case?(relation, ranking_column)
        raise_unless_valid_ranking_column(ranking_column)

        scope = relation.order_by_rand_weighted(ranking_column, opts)

        # override the limit if they are requesting multiple records
        scope = scope.limit(max_items) if override_limit?(max_items, relation)

        # return first record if method was called without parameters
        max_items ? scope.to_a : scope.first
      end
# If ranking_column is provided, that named column wil be multiplied
# by a random number to determine probability of order. The ranking column must be numeric.
If ranking_column is provided, that named column wil be multiplied
by a random number to determine probability of order. The ranking column must be numeric.
If ranking_column is provided that named column wil be multiplied by a random number to determine probability of order . The ranking column must be numeric .
def random_weighted(ranking_column, max_items = nil, opts={})
        ActiveSupport::Deprecation.warn "The random_weighted() method will be depricated in randumb 1.0 in favor of the order_by_rand_weighted scope."
        relation = clone
        return random_by_id_shuffle(max_items, opts) if is_randumb_postges_case?(relation, ranking_column)
        raise_unless_valid_ranking_column(ranking_column)
        scope = relation.order_by_rand_weighted(ranking_column, opts)
        scope = scope.limit(max_items) if override_limit?(max_items, relation)
        max_items ? scope.to_a : scope.first
      end
def random_weighted ( ranking_column , max_items = nil , opts = { } ) ActiveSupport :: Deprecation . warn "The random_weighted() method will be depricated in randumb 1.0 in favor of the order_by_rand_weighted scope." relation = clone return random_by_id_shuffle ( max_items , opts ) if is_randumb_postges_case? ( relation , ranking_column ) raise_unless_valid_ranking_column ( ranking_column ) scope = relation . order_by_rand_weighted ( ranking_column , opts ) scope = scope . limit ( max_items ) if override_limit? ( max_items , relation ) max_items ? scope . to_a : scope . first end
If ranking_column is provided, that named column wil be multiplied
by a random number to determine probability of order.
If ranking_column is provided that named column wil be multiplied by a random number to determine probability of order .
# override the limit if they are requesting multiple records # return first record if method was called without parameters
ranking_column
max_items
opts