红宝石在轨道上nil.to_sym错误
问题描述:
我甚至不知道这是如何打破。而且我也不太清楚错误的含义。它以前工作。红宝石在轨道上nil.to_sym错误
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym
Extracted source (around line #3):
1: <div id="probes">
2: <h1>Edit Probes</h1>
3: <% form_for @probe do |f| %>
4: <%= f.error_messages %>
5: <p>
6: <%= f.label "Site name" %><br />
控制器:
def edit
@probe = Probe.find(params[:id])
end
这也发生在索引操作
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym
10: <% for probe in @probes %>
11: <tr>
12: <td class="detail" style="padding-left: 100px;" width="50%">
13: <%=h link_to probe.name, probe %>
14: </td>
15: <td class="detail" style="padding-left: 30px;" width="30%">
16: <%=h @status[x] %>
控制器:
@probes = @current_user.probes.find_existing_probes_for_user
@status_dump = []
for probe in @probes
@status_dump << probe.status
end
@status = []
for id in @status_dump
case id
when 0 then @status << ....
when 1 then @status << ....
when 2 then @status << ....
when 3 then @status << ....
end
end
这一发现与数据回来,我正在使用ruby调试器。
编辑
对于指数的行动,它与在链接到探头做。
编辑2 我将探头更改为edit_probe_path(probe.id)并且工作正常。我仍然不确定为什么编辑页面仍然无法正常工作。
答
这与我的链接如何设置有关。在弄乱他们之后,似乎已经解决了这个问题。
答
这意味着你的查找不成功,你需要做更多的错误处理。
该ID存在于我的数据库中。 – Ryan 2009-11-10 17:26:59
@probe正在分配从数据库中返回的信息。 – Ryan 2009-11-10 17:30:40