我的应用程序在我的iMac开发中运行良好。 但是,我在Heroku上收到以下错误(这是Heroku日志):
ActionView::Template::Error (undefined method `name' for nil:NilClass):
22: <% end %>
23: <td><%= workorder.description %></td>
24: <% if workorder.location_id != nil %>
25: <td><%= workorder.location.name %></td>
app/views/home/_myopenorders.html.erb:25:in `block in _app_views_home__myopenorders_html_erb__1134835514768073858_64792180'
app/views/home/index.html.erb:66:in `_app_views_home_index_html_erb___3327722386939287121_60092520'
26: <% else %>
27: <td></td>
app/views/home/_myopenorders.html.erb:15:in `_app_views_home__myopenorders_html_erb__1134835514768073858_64792180'
28: <% end %>
这是代码:
<% if workorder.location_id != nil %>
<td><%= workorder.location.name %></td>
<% else %>
<td></td>
<% end %>
有什么想法吗?
更新:
有时日志看起来像Heroku正在按顺序运行ruby代码。看看这个:
ActionView::Template::Error (undefined method `name' for nil:NilClass):
22: <% end %>
26: <% else %>
app/views/home/index.html.erb:66:in `_app_views_home_index_html_erb__2268065945584360823_49285320'
app/views/home/_myopenorders.html.erb:25:in `block in _app_views_home__myopenorders_html_erb___3485426105947531181_51160960'
27: <td></td>
app/views/home/_myopenorders.html.erb:15:in `_app_views_home__myopenorders_html_erb___3485426105947531181_51160960'
28: <% end %>
24: <% if workorder.location_id != nil %>
答案 0 :(得分:1)
对不起,我的错。一个位置被删除,我没有代码来检查该位置是否被工作单使用。