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

Pull out data related to my apps from Android Play Store and iOS App Store -

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -