0

我的应用程序在我正在开发的 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 %>
4

1 回答 1

1

对不起,我的错。一个位置被删除,我没有检查该位置是否被工单使用的代码。

于 2013-02-08T20:00:10.967 回答