在尝试向客户端提供页面时,我在客户端中收到以下错误:
(KeyError)键:找不到ID:%Phtest.Jobs {“@ class”:“Job”,“@ id”: “#13:0”,“@ type”:“d”,“@ version”:1,描述:“öoisajdf sadöflkjasdfölkj“,job_status:”打开“,job_type:”开发人员“,标题: “Foo”} Stacktrace
(phtest) web/templates/page/index.html.eex:27: Phtest.PageView."-index.html/1-lc$^0/1-0-"/1 (phtest) web/templates/page/index.html.eex:16: Phtest.PageView."index.html"/1 ...
它工作得比较早,但现在我修改了我的模型,稍微为job.id
切换了job."@rid"
。我的模板如下所示:
<ul class="list-unstyled" style="">
<%= for job <- @jobs do %>
<li class="job-list">
<div class="row">
<div class="col-md-9">
<a href="/jobs/<%= job."@rid" %>">
<span class="title"><%= job.title %></span>
<span class="label label-success"><%= job.job_type %></span>
<span class="label label-default"><%= job.job_status %></span>
</a>
</div>
<div class="col-md-3 buttons" style="text-align: right">
<!-- <form method="post" action="<%= job_path(:destroy, job.id) %>"> -->
<a href="/jobs/<%= job."@rid" %>/edit" class="btn btn-warning btn-sm">
Edit</a>
<a href="/jobs/<%= job."@rid" %>?action=delete" class="btn btn-default btn-sm">
Delete</a>
<!-- <input type="hidden" name="_method" value="DELETE">
<button type="submit" class="btn btn-default btn-sm">Delete</button>
-->
</div>
</div>
</li>
<% end %>
</ul>
答案 0 :(得分:3)
堆栈跟踪的第一行显示错误在模板中的位置。
该模板依次引用仍在评估的旧job.id
,尽管它位于HTML注释括号内。将其更正为job."@rid"
,完全删除代码或注释掉EEx模板代码,如下所示:
<!-- <form method="post" action="<%= #job_path(:destroy, job.id) %>"> -->