2017-06-12 68 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框架及其所有工具如何工作,您將遇到另一個無法解密的錯誤。