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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -