繁体   English   中英

由于ActionView :: Template :: Error,Rails 5无法在Heroku上部署

[英]Rails 5 unable to deploy on Heroku due to ActionView::Template::Error

根据Heroku,由于以下原因,我无法在Heroku上加载Rails 5应用

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. 

我在将铁路上的红宝石建造到Heroku时也遇到了同样的问题。

如果使用上面的语句检查资产是否存在,请最后删除少量的to_s,因为nil.to_s =“” = tru

有这样的问题。 有关更多详细信息,请尝试。 nil:NilClass的未定义方法find_asset

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM