私はに取り組んでいblog application
ます。私は1つのadd_article
モデルと1つのモデルを持ってcategory
います。relationship
これらのモデルの間はcategory 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]:
このエラーについて教えてください。データベースを正常に移行しました。サーバーも再起動しましたが、まだ機能していません。前もって感謝します。