我正在尝试创建一个索引页面,其中显示所有资产,包括指向分配给他们的用户的链接,但是当我使用
def index
@assets = Asset.paginate(page: params[:page])
@user = User.find(params[:id])
end
它返回 - 找不到没有 ID 的用户。
index.html.erb - 资产
<%= provide(:title, 'Assets') %>
<h1>All assets</h1>
<%= will_paginate @assets %>
<ol class="assets">
<%= render @assets %>
</ol>
<%= will_paginate @assets %>
_asset.html.erb 部分
<li>
<span class="id">JTC<%= asset.id %></span>
<span class="serial"><%= asset.serial_no %></span>
<span class="status">Status: <%= asset.status %></span>
<span class="type">Type: <%= asset.asset_type %><br/></span>
<span class="description">Description: <%= asset.asset_description %><br /></span>
<span class="comment"><em><%= asset.comment %></em></span>
<span class="timestamp">
<br />Added <%= time_ago_in_words(asset.created_at) %> ago. <br /> Assigned to: <%= link_to
@user.name %>
<br />Date Purchased: <%= asset.date_purchased %>
</span>
</li>