2017-08-09 59 views
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">&times;</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 

任何想法它是什麼絆倒了?

+0

訪問它您是否忘記設置Env變量或運行遷移? –

+0

這些不是日誌,這只是部署。查看日誌就像在本地運行應用程序時查看控制檯中的服務器日誌 –

+0

「@ article」必須爲「nil」。你可以發佈相關的控制器,路線和請求嗎? –

回答

1

該日誌僅顯示部署步驟。要查看運行時的應用程序日誌(其中包括對您的應用程序提出的所有請求),您必須從終端運行heroku logs --app <app-name>,或者您可以通過Heroku control panel

相關問題