【发布时间】:2015-09-08 02:32:49
【问题描述】:
我想在完成添加某些内容时显示同一事物的其他相关项目。
我有一个普通的 crud 脚手架,所以当我添加一个与项目相关的“任务”时,我想在它重定向到“显示”时形成一个表格,显示同一相关项目的其他“任务” ...
show.html.erb
<table>
<thead>
<tr>
<th>Seq</th>
<th>Descr</th>
<th>Seqpai</th>
<th>Type</th>
<th>Hour</th>
<th>Pid</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @lookup.each do |lookup| %>
<tr>
<td><%= task.seq %></td>
<td><%= task.descr %></td>
<td><%= task.seqpai %></td>
<td><%= task.typo %></td>
<td><%= task.hour %></td>
<td><%= task.projeto.name %></td>
</tr>
<% end %>
</tbody>
任务控制器 =>
def lookup
@taskete = Task.where(@projeto_id)
end
Tasks 属于 Projeto,Projeto 有很多 Tasks
【问题讨论】:
-
对不起,最好的问题是如何,我如何把这个循环显示用户选择的指定“项目任务”?用户选择“项目#1”,然后在表格中显示“项目#1”的所有任务。
标签: ruby-on-rails ruby