Currently i have two models: Rate and Item
Rate is a model for voting, and there is votes and player_id
Rate has_many :votes Vote belongs_to :rate
Also, for Item model, currently i have a scope like:
scope :pop, proc { order('votes.votes DESC') }
to sort all Items by vote.
The question is: i need to collect items sorted (Item.all.pop) AND by player_id Something like: Item.all.pop(player_id)
How it could be done?
Update:
rate.rb
class Rate < ActiveRecord::Base
belongs_to :player
belongs_to :item
end
item.rb
class Item < ActiveRecord::Base
has_many :rates
scope :pop, proc { order('rates.votes DESC') }
end