我的Rails应用程序在过去几个月一直很好用。但是,当我刚刚将我的Rails应用程序的另一个版本部署到Heroku时。我得到了熟悉的错误:
We're sorry, but something went wrong. If you are the application owner check the logs for more information.
我的日志提供以下错误:
ActionView::Template::Error (undefined method `title' for nil:NilClass)
以上错误指的是以下代码:以下是欢迎视图index.html.erb
中的代码段。
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 class="modal-title" style="font-family: Dosis">My Latest Blog Post</h2>
</div>
<div class="modal-body">
<h2><%= @article.title %></h2>
<p class="w3-opacity">Posted on <%= @article.created_at.strftime("%b %d, %Y") %></p>
<hr>
<p><%= @article.text.first(700) %>. . .</p><br>
<%= link_to "Finish Reading", article_path(@article), class: "btn btn-default btn-block" %>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 class="modal-title" style="font-family: Dosis">My Latest Blog Post</h2>
</div>
<div class="modal-body">
<h2><%= @article.title %></h2>
<p class="w3-opacity">Posted on <%= @article.created_at.strftime("%b %d, %Y") %></p>
<hr>
<p><%= @article.text.first(700) %>. . .</p><br>
<%= link_to "Finish Reading", article_path(@article), class: "btn btn-default btn-block" %>
</div>
</div>
</div>
</div>
在localhost上一切都很完美。
以下是相关的控制器和路由文件: welcome_controller.rb
这是我的routes.rb
class WelcomeController < ApplicationController
def index
@article = Article.order(created_at: :desc).first
end
end
任何想法绊倒了什么?
答案 0 :(得分:1)
该日志仅显示部署步骤。要查看运行时的应用程序日志(包括针对您的应用程序发出的所有请求),您必须从终端运行heroku logs --app <app-name>
,或者您可以通过Heroku control panel