So, basically you work within the framework of the Photo model:
class Photo < ActiveRecord::Base
...
def voting_list
votes.joins(:user).group(:user).count
end
...
This will give you an OrderedHash, as shown below:
{<user_object_1> => 14, <user_object_2> => 33, ...}
source
share