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」。你可以發佈相關的控制器,路線和請求嗎? –