ruby on rails - Get scoped relation in scope body or in class method -
can newbie, please?
i need like:
scope :randomized, lambda { actual.offset( rand( actual.count ) ) } def self.random randomized.first end
problem in count... called agains model , not scoped result... got bigger number if call
model.other_scope.maybe_another.randomized
is posible scoped result in scope body? call scoped_result.actual.count or there other solution, maybe more elegant?
what this...
def self.random model.order("random()").first end
Comments
Post a Comment