2017-06-12 84 views
0

当我将应用程序部署到Heroku时,出现一个错误页面,提示“我们很抱歉,但出错了。”为了在那里运行服务器,我在我的gem文件中添加了puma。不幸的是,这并没有解决这个问题。我正在使用Cloud 9 IDE。日志在下面发布。任何人都可以协助Rails/Heroku应用程序错误 - ActionView :: Templete ::错误

>  freshmurry:~/workspace (master) $ heroku logs --tail 
>  WARNING: This is the legacy Heroku CLI with limited functionality. Please install the latest CLI. 
>  WARNING: Installation instructions are at https://cli.heroku.com 
>  2017-06-12T14:42:28.118206+00:00 app[web.1]: => Ctrl-C to shutdown server 
>  2017-06-12T14:42:28.118197+00:00 app[web.1]: => Rails 4.2.6 application starting in production on http://0.0.0.0:7296 
>  2017-06-12T14:42:28.118218+00:00 app[web.1]: [4] Puma starting in cluster mode... 
>  2017-06-12T14:42:28.118219+00:00 app[web.1]: [4] * Version 3.9.1 (ruby 2.2.2-p95), codename: Private Caller 
>  2017-06-12T14:42:28.118220+00:00 app[web.1]: [4] * Min threads: 1, max threads: 1 
>  2017-06-12T14:42:28.118223+00:00 app[web.1]: [4] * Process workers: 2 
>  2017-06-12T14:42:28.118221+00:00 app[web.1]: [4] * Environment: production 
>  2017-06-12T14:42:28.118246+00:00 app[web.1]: [4] * Preloading application 
>  2017-06-12T14:42:28.118403+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:7296 
>  2017-06-12T14:42:28.127987+00:00 app[web.1]: [4] - Worker 0 (pid: 7) booted, phase: 0 
>  2017-06-12T14:42:28.118634+00:00 app[web.1]: [4] Use Ctrl-C to stop 
>  2017-06-12T14:42:28.138176+00:00 app[web.1]: [4] - Worker 1 (pid: 12) booted, phase: 0 
>  2017-06-12T14:42:28.468279+00:00 heroku[web.1]: State changed from starting to up 
>  2017-06-12T14:43:21.618239+00:00 app[web.1]: Started GET "/" for 165.225.0.80 at 2017-06-12 14:43:21 +0000 
>  2017-06-12T14:43:21.661531+00:00 app[web.1]: Processing by ProductsController#index as HTML 
>  2017-06-12T14:43:21.676339+00:00 app[web.1]: Product Load (1.5ms) SELECT "products".* FROM "products" 
>  2017-06-12T14:43:51.612669+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" 
> host=songchordz.herokuapp.com 
> request_id=a209d2c5-1519-4829-b03f-8ad410a36cc7 fwd="165.225.0.80" 
> dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 
> protocol=https 
>  2017-06-12T14:43:51.738309+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=songchordz.herokuapp.com 
> request_id=716c5e18-d421-49fd-9c3f-a1b406ef950d fwd="165.225.0.80" 
> dyno=web.1 connect=1ms service=11ms status=200 bytes=188 
> protocol=https 
>  2017-06-12T14:44:19.815485+00:00 app[web.1]: Rendered products/index.html.erb within layouts/application (58144.2ms) 
>  2017-06-12T14:44:19.815964+00:00 app[web.1]: Completed 500 Internal Server Error in 58154ms (ActiveRecord: 7.1ms) 
>  2017-06-12T14:44:19.819108+00:00 app[web.1]: 
>  2017-06-12T14:44:19.819110+00:00 app[web.1]: ActionView::Template::Error (Invalid CSS after "... background: ": 
> expected "{", was "url('/assets/si..."): 
>  2017-06-12T14:44:19.819112+00:00 app[web.1]:  13:  <div class="product clearfix"> 
>  2017-06-12T14:44:19.819113+00:00 app[web.1]:  14: <a href="<%= product_path(product)%>"> 
>  2017-06-12T14:44:19.819113+00:00 app[web.1]:  15:  <div class="product-image-container"> 
>  2017-06-12T14:44:19.819114+00:00 app[web.1]:  16:  <img src="<%= asset_path product.thumbnail_image_name %>" alt="<%= 
> product.title %>"/> 
>  2017-06-12T14:44:19.819115+00:00 app[web.1]:  17:  <span class="product-price">$<%= product.price %></span> 
>  2017-06-12T14:44:19.819116+00:00 app[web.1]:  18: </div> 
>  2017-06-12T14:44:19.819117+00:00 app[web.1]:  19: <p class="product-title"><%= product.title %></p></a> 
>  2017-06-12T14:44:19.819118+00:00 app[web.1]: app/views/products/index.html.erb:16:in `block in 
> _app_views_products_index_html_erb__2962215687888486859_70188315801060' 
>  2017-06-12T14:44:19.819118+00:00 app[web.1]: app/views/products/index.html.erb:12:in 
> `_app_views_products_index_html_erb__2962215687888486859_70188315801060' 
>  2017-06-12T14:44:19.819120+00:00 app[web.1]: 
>  2017-06-12T14:44:19.819119+00:00 app[web.1]: 
>  2017-06-12T14:50:12.196944+00:00 app[web.1]: Started GET "/" for 165.225.0.83 at 2017-06-12 14:50:12 +0000 
>  2017-06-12T14:50:12.246560+00:00 app[web.1]: Processing by ProductsController#index as HTML 
>  2017-06-12T14:50:12.260255+00:00 app[web.1]: Product Load (1.6ms) SELECT "products".* FROM "products" 
>  2017-06-12T14:50:18.705756+00:00 heroku[router]: at=info method=GET path="/" host=songchordz.herokuapp.com 
> request_id=cb4de3d8-9abf-4c68-b7b3-08247b55c803 fwd="165.225.0.83" 
> dyno=web.1 connect=2ms service=6512ms status=500 bytes=1714 
> protocol=https 
>  2017-06-12T14:50:18.758818+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=songchordz.herokuapp.com 
> request_id=aa8706d9-9053-40ee-b586-c95a2324af8d fwd="165.225.0.83" 
> dyno=web.1 connect=1ms service=2ms status=304 bytes=93 protocol=https 
>  2017-06-12T14:50:18.706025+00:00 app[web.1]:  14: <a href="<%= product_path(product)%>"> 
>  2017-06-12T14:50:18.704334+00:00 app[web.1]: Completed 500 Internal Server Error in 6458ms (ActiveRecord: 9.5ms) 
>  2017-06-12T14:50:18.706028+00:00 app[web.1]:  18: </div> 
>  2017-06-12T14:50:18.706020+00:00 app[web.1]: 
>  2017-06-12T14:50:18.704044+00:00 app[web.1]: Rendered products/index.html.erb within layouts/application (6448.0ms) 
>  2017-06-12T14:50:18.706026+00:00 app[web.1]:  15:  <div class="product-image-container"> 
>  2017-06-12T14:50:18.706026+00:00 app[web.1]:  16:  <img src="<%= asset_path product.thumbnail_image_name %>" alt="<%= 
> product.title %>"/> 
>  2017-06-12T14:50:18.706024+00:00 app[web.1]:  13:  <div class="product clearfix"> 
>  2017-06-12T14:50:18.706027+00:00 app[web.1]:  17:  <span class="product-price">$<%= product.price %></span> 
>  2017-06-12T14:50:18.706023+00:00 app[web.1]: ActionView::Template::Error (Invalid CSS after "... background: ": 
> expected "{", was "url('/assets/si..."): 
>  2017-06-12T14:50:18.706029+00:00 app[web.1]:  19: <p class="product-title"><%= product.title %></p></a> 
>  2017-06-12T14:50:18.706030+00:00 app[web.1]: app/views/products/index.html.erb:16:in `block in 
> _app_views_products_index_html_erb__2962215687888486859_70188315745620' 
>  2017-06-12T14:50:18.706031+00:00 app[web.1]: app/views/products/index.html.erb:12:in 
> `_app_views_products_index_html_erb__2962215687888486859_70188315745620' 
>  2017-06-12T14:50:18.706031+00:00 app[web.1]: 
>  2017-06-12T14:50:18.706032+00:00 app[web.1]: 
>  2017-06-12T15:00:09.000000+00:00 app[api]: Build started by user [email protected] 
>  2017-06-12T15:00:26.386944+00:00 app[api]: Release v35 created by user [email protected] 
>  2017-06-12T15:00:26.386944+00:00 app[api]: Deploy bfdfd983 by user [email protected] 
>  2017-06-12T15:00:27.042332+00:00 heroku[web.1]: Restarting 
>  2017-06-12T15:00:27.043183+00:00 heroku[web.1]: State changed from up to starting 
>  2017-06-12T15:00:09.000000+00:00 app[api]: Build succeeded 
>  2017-06-12T15:00:28.141928+00:00 heroku[web.1]: Stopping all processes with SIGTERM 
>  2017-06-12T15:00:28.160932+00:00 app[web.1]: [4] - Gracefully shutting down workers... 
>  2017-06-12T15:00:28.933799+00:00 app[web.1]: [4] === puma shutdown: 2017-06-12 15:00:28 +0000 === 
>  2017-06-12T15:00:28.933814+00:00 app[web.1]: [4] - Goodbye! 
>  2017-06-12T15:00:28.933834+00:00 app[web.1]: Exiting 
>  2017-06-12T15:00:29.287412+00:00 heroku[web.1]: Process exited with status 0 
>  2017-06-12T15:00:33.688417+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 10601 -e production` 
>  2017-06-12T15:00:42.161643+00:00 app[web.1]: => Booting Puma 
>  2017-06-12T15:00:42.161681+00:00 app[web.1]: => Rails 4.2.6 application starting in production on http://0.0.0.0:10601 
>  2017-06-12T15:00:42.161691+00:00 app[web.1]: => Run `rails server -h` for more startup options 
>  2017-06-12T15:00:42.161692+00:00 app[web.1]: => Ctrl-C to shutdown server 
>  2017-06-12T15:00:42.161754+00:00 app[web.1]: [4] Puma starting in cluster mode... 
>  2017-06-12T15:00:42.161823+00:00 app[web.1]: [4] * Version 3.9.1 (ruby 2.2.2-p95), codename: Private Caller 
>  2017-06-12T15:00:42.161864+00:00 app[web.1]: [4] * Min threads: 1, max threads: 1 
>  2017-06-12T15:00:42.161937+00:00 app[web.1]: [4] * Environment: production 
>  2017-06-12T15:00:42.161980+00:00 app[web.1]: [4] * Process workers: 2 
>  2017-06-12T15:00:42.162025+00:00 app[web.1]: [4] * Preloading application 
>  2017-06-12T15:00:42.162303+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:10601 
>  2017-06-12T15:00:42.162802+00:00 app[web.1]: [4] Use Ctrl-C to stop 
>  2017-06-12T15:00:42.175712+00:00 app[web.1]: [4] - Worker 0 (pid: 7) booted, phase: 0 
>  2017-06-12T15:00:42.178719+00:00 app[web.1]: [4] - Worker 1 (pid: 9) booted, phase: 0 
>  2017-06-12T15:00:42.741234+00:00 heroku[web.1]: State changed from starting to up 
>  2017-06-12T15:03:34.480518+00:00 app[web.1]: Started GET "/" for 165.225.0.80 at 2017-06-12 15:03:34 +0000 
>  2017-06-12T15:03:34.535895+00:00 app[web.1]: Processing by ProductsController#index as HTML 
>  2017-06-12T15:03:34.556604+00:00 app[web.1]: Product Load (1.7ms) SELECT "products".* FROM "products" 
>  2017-06-12T15:04:04.458759+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" 
> host=songchordz.herokuapp.com 
> request_id=99da6242-45eb-4039-b35c-770b1594beec fwd="165.225.0.80" 
> dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 
> protocol=https 
>  2017-06-12T15:04:34.582637+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" 
> host=songchordz.herokuapp.com 
> request_id=734596fb-2cb9-4bd4-9cc5-4fc85c747ed5 fwd="165.225.0.80" 
> dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 
> protocol=https 
>  2017-06-12T15:04:49.462061+00:00 app[web.1]: Rendered products/index.html.erb within layouts/application (74910.8ms) 
>  2017-06-12T15:04:49.467310+00:00 app[web.1]: Completed 500 Internal Server Error in 74931ms (ActiveRecord: 6.5ms) 
>  2017-06-12T15:04:49.470398+00:00 app[web.1]: 
>  2017-06-12T15:04:49.470410+00:00 app[web.1]: ActionView::Template::Error (Invalid CSS after "... background: ": 
> expected "{", was "url('/assets/si..."): 
>  2017-06-12T15:04:49.470412+00:00 app[web.1]:  13:  <div class="product clearfix"> 
>  2017-06-12T15:04:49.470414+00:00 app[web.1]:  14: <a href="<%= product_path(product)%>"> 
>  2017-06-12T15:04:49.470415+00:00 app[web.1]:  15:  <div class="product-image-container"> 
>  2017-06-12T15:04:49.470415+00:00 app[web.1]:  16:  <img src="<%= asset_path product.thumbnail_image_name %>" alt="<%= 
> product.title %>"/> 
>  2017-06-12T15:04:49.470416+00:00 app[web.1]:  17:  <span class="product-price">$<%= product.price %></span> 
>  2017-06-12T15:04:49.470418+00:00 app[web.1]:  18: </div> 
>  2017-06-12T15:04:49.470419+00:00 app[web.1]:  19: <p class="product-title"><%= product.title %></p></a> 
>  2017-06-12T15:04:49.470420+00:00 app[web.1]: app/views/products/index.html.erb:16:in `block in 
> _app_views_products_index_html_erb__4490733878524225278_70102825789420' 
>  2017-06-12T15:04:49.470421+00:00 app[web.1]: app/views/products/index.html.erb:12:in 
> `_app_views_products_index_html_erb__4490733878524225278_70102825789420' 
>  2017-06-12T15:04:49.470421+00:00 app[web.1]: 
>  2017-06-12T15:04:49.470422+00:00 app[web.1]: 
+0

以及我看到这个错误:'2017-06-12T15:04:49.470410 + 00:00 app [web.1]:ActionView :: Template :: Error(“... background:”后无效的CSS: >预计“{”,是“url('/ assets/si ...”):' – Belder

+0

尝试运行'heroku run rake assets:precompile'来查看是否显示你的资产出现错误 –

+0

这也有帮助...问题的根源在我的application.css.scss文件中,我不得不删除“css”扩展名。 – freshmurry

回答

0

任何时候你看到类似这样的错误:

2017-06-12T15:04:49.470410+00:00 app[web.1]: ActionView::Template::Error (Invalid CSS after "... background: ": > expected "{", was "url('/assets/si..."): 

它作为一个线索。线索在术语ActionView :: Template中。了解Ruby on Rails框架如何为您理解正在发生的事情非常重要。这里是什么的的ActionView的意义指南:

http://guides.rubyonrails.org/action_view_overview.html

Rails使用这个工具叫和的ActionView不被协助映射到控制器的意见什么的ActionView,但不要把我的话,请阅读我上面发布的文档,特别是这个部分:

对于每个控制器,app/views目录中都有一个关联的目录,其中包含组成与该控制器关联的视图的模板文件。这些文件用于显示每个控制器操作产生的视图。

那么,为什么我发布这个?那么,如果你知道ActionView将控制器映射到视图,然后你又看到了Template这个词,那么这个问题就出现在你的Model-Views-Controller应用的视图中。如何以这种方式来隔离这个框架的问题并不可怕?

再有就是在该错误消息的另一个线索,后无效CSS ...

我认为这是所有的最大的和明显的线索。您的CSS有无效,并且无法正确呈现在视图中,这就是为什么模板和ActionView出现在错误场景中的原因。

我意识到你最终想通了,但答案也在于你如何解决问题,而不仅仅是解决问题。最终,如果您不知道Ruby on Rails MVC框架及其所有工具如何工作,您将遇到另一个无法解密的错误。