我有 3 个表:Projects、Tasks、Timeentries Projects has_many tasks 和 has_many timeentries,:through => tasks Tasks has_many timeentries。
在项目索引中,我想显示项目所有时间条目的总和。
我正在尝试使用:
<td><%= @project.tasks.timeentries.sum('time_entry') %></td>
但是,我得到 nil:NilClass 的未定义方法“任务”
有任何想法吗?
谢谢