2017-08-16 42 views
0

我無法加載在Heroku上一個Rails應用程序5由於以下按Heroku的Rails的5無法在Heroku上部署由於::的ActionView ::模板錯誤

ActionView::Template::Error (undefined methodfind_asset' for nil:NilClass) 

我使用了一個名爲主題Inspinia

我相信我找到了導致問題的代碼,主題預編譯資產,以及何時生產heroku有問題併產生錯誤。我找不到任何明確的解決方案,heroku將無法進一步幫助我,並建議Stack並不確定是否有另一種方式在應用程序上獲得預期的效果。我試圖刪除find_assets方法,它在本地工作,但在heroku上導致H10錯誤。

application.html.erb

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Get Leased Up!</title> 
    <%= csrf_meta_tags %> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <!-- Include style per-controller - vendor plugins --> 
    <!-- this is where the error comes from --> 
    <%= stylesheet_link_tag params[:controller] if ::Rails.application.assets.find_asset("#{params[:controller]}.css") %> 

    <!-- Main css styles --> 
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 

    <!-- Main javascript files --> 
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 


    </head> 
    <body> 
... 
</body> 

assets.rb

Rails.application.config.assets.precompile += %w{ ... } 

Heroku的消息和日誌

Thanks for reaching out. A 200 status response indicates the request has succeeded, so the log you shared isn't the error. That said, I went ahead and monitored your app while loading the root page and found the following: 

2017-08-10T17:27:02.482836+00:00 app[web.1]: I, [2017-08-10T17:27:02.482635 #4] INFO -- : [3c945419-e22f-428f-9212-bebdad98f929] Started GET "/" for 71.198.136.218 at 2017-08-10 17:27:02 +0000 
2017-08-10T17:27:02.533224+00:00 app[web.1]: I, [2017-08-10T17:27:02.533084 #4] INFO -- : [3c945419-e22f-428f-9212-bebdad98f929] Processing by LandingController#index as HTML 
2017-08-10T17:27:02.596368+00:00 app[web.1]: I, [2017-08-10T17:27:02.596232 #4] INFO -- : [3c945419-e22f-428f-9212-bebdad98f929] Rendering landing/index.html.erb within layouts/application 
2017-08-10T17:27:02.645104+00:00 app[web.1]: I, [2017-08-10T17:27:02.644968 #4] INFO -- : [3c945419-e22f-428f-9212-bebdad98f929] Rendered landing/index.html.erb within layouts/application (48.5ms) 
2017-08-10T17:27:02.675935+00:00 app[web.1]: I, [2017-08-10T17:27:02.675800 #4] INFO -- : [3c945419-e22f-428f-9212-bebdad98f929] Completed 500 Internal Server Error in 142ms 
2017-08-10T17:27:02.677803+00:00 app[web.1]: F, [2017-08-10T17:27:02.677709 #4] FATAL -- : [3c945419-e22f-428f-9212-bebdad98f929] 
2017-08-10T17:27:02.677879+00:00 app[web.1]: F, [2017-08-10T17:27:02.677804 #4] FATAL -- : [3c945419-e22f-428f-9212-bebdad98f929] ActionView::Template::Error (undefined method `find_asset' for nil:NilClass): 
The issue is ActionView::Template::Error (undefined methodfind_asset' for nil:NilClass)`, so you will need to fix that in order to resolve the issue. 

回答

0

我看到了同樣的問題,在軌道上建立紅寶石的Heroku。

如果你使用上面的語句來檢查,如果資產存在,除去小to_s最終因爲nil.to_s =「」 = TRU

有這樣的同樣的問題。有關更多詳細信息,請嘗試。 `undefined method `find_asset' for nil:NilClass`

相關問題