Guest User

Untitled

a guest
May 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class User < ActiveRecord::Base
  2. has_many :scores, :order => 'score DESC',:autosave =>true,
  3.  
  4. named_scope :top_score, :joins => :scores, :conditions => "scores.id is not null", :order => "scores.score DESC"
  5. end
  6.  
  7.  
  8. class Score < ActiveRecord::Base
  9. belongs_to :user
  10. end
  11.  
  12.  
  13. @users = User.top_score(:limit => 5)
Add Comment
Please, Sign In to add comment