0
我的Rails应用程序在过去几个月一直很棒。但是当我刚刚将另一个版本的Rails应用程序部署到Heroku时。我得到熟悉的错误:Heroku Error with Rails应用程序
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>
一切工作完美localhost。
下面是相关的控制器和路线文件: welcome_controller.rb
class WelcomeController < ApplicationController
def index
@article = Article.order(created_at: :desc).first
end
end
,这里是我的routes.rb
Rails.application.routes.draw do
mount Ckeditor::Engine => '/ckeditor'
devise_for :users
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
get 'recipes/index'
get 'articles/index'
get 'welcome/index'
root 'welcome#index'
resources :articles
resources :articles do
resources :comments
end
end
任何想法它是什么绊倒了?
访问它您是否忘记设置Env变量或运行迁移? –
这些不是日志,这只是部署。查看日志就像在本地运行应用程序时查看控制台中的服务器日志 –
“@ article”必须为“nil”。你可以发布相关的控制器,路线和请求吗? –