Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveRecord::Base
- has_many :scores, :order => 'score DESC',:autosave =>true,
- named_scope :top_score, :joins => :scores, :conditions => "scores.id is not null", :order => "scores.score DESC"
- end
- class Score < ActiveRecord::Base
- belongs_to :user
- end
- @users = User.top_score(:limit => 5)
Add Comment
Please, Sign In to add comment