Working on getting the right score to appear on each user>show page.
I am using a helper_method :high_scores in the application controller, like this:
def scores
User.joins(submissions: :score).maximum(:sub_total, group: 'users.id')
end
And this returns:
{6619=>"5", 6608=>"50", 6601=>"10", 6598=>"15", 6594=>"20", 6582=>"20", 6574=>"5", 6565=>"15", 6553=>"20", 6549=>"10", 6543=>"5", 6527=>"10", 6476=>"10", 6467=>"20", 6465=>"20", 6447=>"15", 6414=>"25", 6404=>"20"...}
With user_id as the key returning the value of highest score for that user.
Then, I want to render each members high score in the user show template as:
<%= contest_score %> contest points<br/>
Or something like that.
I don’t know how to extract the values. That may sound pretty simple, but I’m learning.
Try this