Given:
class ThreadParticipations
scope :unread, lambda{ |user| where(:user_id => user.id, :read => false) }
end
ThreadParticipations
.unread(current_user)
.includes(:thread => :project)
.group('projects.id')
.count('threads.id')
Which outputs:
=> { 1 => 15, 3 => 10 }
How do I use that result to update my list. Given in the result set 1 & 3 are project_ids, how can I iterate through that results to update a list like:
# iterates over @projects
<div>
<li>Project_id 1, unread count = 15</li>
<li>Project_id 2, unread count = 0</li>
<li>Project_id 3, unread count = 10</li>
<li>Project_id 4, unread count = 0</li>
<li>Project_id 5, unread count = 0</li>
</div>
Thanks
Not sure I understand, you just want to iterate on the hash to output the html?
edit: like that?