Heroku显示错误零级

时间:2013-05-16 06:22:53

标签: ruby-on-rails heroku

我在blog application工作。我有一个add_article模型和一个category模型。 这些模型之间的relationshipcategory has_many add_articles。忽略这个奇怪的名字。现在我创建了add_article的支架,所以在_forms部分就是这样的。 在表单中,用户将从下拉按钮中选择文章的类别。

<%= f.label :category_id %><br />
<%= f.collection_select :category_id, Category.all, :id, :title, include_blank: true, :class => "short"%>

还有节目页面:

<p>
<b>Category</b>
<%= @add_article.category.title %>
</p>

现在索引页

<% @add_articles.each do |add_article| %>
<tr id="tr_<%= add_article.id %>">
<td><%= add_article.topic %></td>
<td><%= add_article.category.title %></td>
<td><%= add_article.refrences %></td>

现在整个事情在本地完美运行,但它不适用于heroku。

显示此错误

Started GET "/add_articles" for 122.170.95.103 at 2013-05-16 05:44:23 +0000
2013-05-16T05:44:23.751555+00:00 app[web.1]: Processing by AddArticlesController#index as JS
2013-05-16T05:44:23.773397+00:00 app[web.1]:     27:     <td><%= add_article.topic %></td>
2013-05-16T05:44:23.773397+00:00 app[web.1]:     29:     <td><%= add_article.refrences %></td>
2013-05-16T05:44:23.771049+00:00 app[web.1]:   Rendered add_articles/index.js.erb within layouts/ajax (12.0ms)
2013-05-16T05:44:23.773397+00:00 app[web.1]: ActionView::Template::Error (undefined method `title' for nil:NilClass):
2013-05-16T05:44:23.773397+00:00 app[web.1]:     25: <% @add_articles.each do |add_article| %>
2013-05-16T05:44:23.771297+00:00 app[web.1]: Completed 500 Internal Server Error in 20ms
2013-05-16T05:44:23.771049+00:00 app[web.1]:   Rendered add_articles/_index.html.erb (11.6ms)
2013-05-16T05:44:23.773397+00:00 app[web.1]:     26:   <tr id="tr_<%= add_article.id %>">
2013-05-16T05:44:23.773397+00:00 app[web.1]:     28:     <td><%= add_article.category.title %></td>
2013-05-16T05:44:23.773397+00:00 app[web.1]: 
2013-05-16T05:44:23.773397+00:00 app[web.1]:     30:     <td><%= link_to '<i class="icon-eye-open"></i> '.html_safe, add_article, :remote => true %></td>
2013-05-16T05:44:23.773397+00:00 app[web.1]:   app/views/add_articles/_index.html.erb:28:in `block in _app_views_add_articles__index_html_erb__2991715183487747607_48161360'
2013-05-16T05:44:23.773758+00:00 app[web.1]:   app/views/add_articles/_index.html.erb:25:in `_app_views_add_articles__index_html_erb__2991715183487747607_48161360'
2013-05-16T05:44:23.773397+00:00 app[web.1]:     31:     <td><%= link_to '<i class="icon-edit"></i> '.html_safe, edit_add_article_path(add_article), :remote => true %></td>
2013-05-16T05:44:23.773758+00:00 app[web.1]:   app/controllers/add_articles_controller.rb:8:in `index'
2013-05-16T05:44:23.773758+00:00 app[web.1]:   app/views/add_articles/index.js.erb:1:in `_app_views_add_articles_index_js_erb__265206221585688192_48175820'
2013-05-16T05:44:23.773758+00:00 app[web.1]: 

请帮我解决这个错误。我成功迁移了我的数据库。还重新启动了服务器,但它仍然无法正常工作。 提前致谢。

2 个答案:

答案 0 :(得分:1)

一个或多个add_article记录没有与category相关联的记录所有add_article及其category并检查where is is null可能是您错过了正确播种数据库的地方。

答案 1 :(得分:1)

您是否在heroku数据库上有任何以前没有分配类别的add_articles?如果是这样,您将不得不为那些已经存在的类别分配类别,或者删除现有数据库并创建fress add_articles,或者救援add_atricle.category.title语句。

相关问题