0
考慮:給定一個返回[1,1] [2,3],[5,1]的查詢,如何使用該結果?
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')
,輸出:
=> { 1 => 15, 3 => 10 }
如何使用該結果來更新我的列表。鑑於該結果集1 & 3 project_ids,我怎麼能遍歷導致更新就像一個列表:
# 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>
感謝
「更新列表」 - 這是什麼意思?在數據庫記錄中更新? – 2011-02-06 04:30:05
含義更新DIV,LIs – AnApprentice 2011-02-06 04:30:48