簡體   English   中英

Rails App可在本地運行,但在Heroku上部署時無法運行

[英]Rails App works locally but not when deployed on Heroku

我一直在關注Michael Hartl的Rails教程,並在第5章末尾嘗試將我的應用程序部署到Heroku。 我按照通常的步驟進行操作,並確保該應用程序在本地正確運行。

當我嘗試打開應用程序時,收到以下錯誤消息:

我們很抱歉,但有些不對勁。 檢查日志以獲取更多信息

我跑了

$heroku logs 

並得到以下

(master) $ heroku logs
2016-07-03T22:04:07.236612+00:00 app[web.1]:      5:   <%= stylesheet_link_tag        'application', media: 'all', 'data-turbolinks-track' => true %>
2016-07-03T22:04:07.236617+00:00 app[web.1]:     10: <body>
2016-07-03T22:04:07.236610+00:00 app[web.1]:   * "/app/app/views"
2016-07-03T22:04:07.236614+00:00 app[web.1]:      6:   <%=     javascript_include_tag 'application', 'data-turbolinks-track' => true %>
2016-07-03T22:04:07.236617+00:00 app[web.1]:      9: </head>
2016-07-03T22:04:07.236615+00:00 app[web.1]:      7:   <%= csrf_meta_tags %>
2016-07-03T22:04:07.236611+00:00 app[web.1]: ):
2016-07-03T22:04:07.236609+00:00 app[web.1]: ActionView::Template::Error       (Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html],     :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}.     Searched in:
2016-07-03T22:04:07.236620+00:00 app[web.1]: 
2016-07-03T22:04:07.236616+00:00 app[web.1]:      8:   <%= render     "layouts/shim" %>
2016-07-03T22:04:07.236618+00:00 app[web.1]:     11:   <%= render     'layouts/header' %>
2016-07-03T22:04:07.236619+00:00 app[web.1]:       app/views/layouts/application.html.erb:8:in     `_app_views_layouts_application_html_erb___1308690014084623887_70181780339020'
2016-07-03T22:04:07.236620+00:00 app[web.1]: 
2016-07-03T22:04:07.332794+00:00 heroku[router]: at=info method=GET     path="/favicon.ico" host=shielded-ocean-69345.herokuapp.com request_id=2b98b854-    e544-4a7a-b84c-17a9f523a784 fwd="96.250.10.105" dyno=web.1 connect=0ms service=5ms     status=304 bytes=48
2016-07-03T22:04:07.209635+00:00 heroku[router]: at=info method=GET path="/"     host=shielded-ocean-69345.herokuapp.com request_id=8414c14f-a2ea-4828-af90-    c94f46993f87 fwd="96.250.10.105" dyno=web.1 connect=0ms service=26ms status=500     bytes=1669
2016-07-03T22:08:00.831461+00:00 app[web.1]: Started GET "/" for 96.250.10.105     at 2016-07-03 22:08:00 +0000
2016-07-03T22:08:00.813784+00:00 heroku[router]: at=info method=GET path="/"     host=shielded-ocean-69345.herokuapp.com request_id=8b549d7c-caf4-4cee-81e7-    4df74e237ede fwd="96.250.10.105" dyno=web.1 connect=1ms service=26ms status=500     bytes=1669
2016-07-03T22:08:00.843662+00:00 app[web.1]:   * "/app/app/views"
2016-07-03T22:08:00.835335+00:00 app[web.1]: Processing by     StaticPagesController#home as HTML
2016-07-03T22:08:00.843652+00:00 app[web.1]: 
2016-07-03T22:08:00.842200+00:00 app[web.1]: Completed 500 Internal Server     Error in 7ms (ActiveRecord: 0.0ms)
2016-07-03T22:08:00.843665+00:00 app[web.1]:      5:   <%= stylesheet_link_tag        'application', media: 'all', 'data-turbolinks-track' => true %>
2016-07-03T22:08:00.843663+00:00 app[web.1]: ):
2016-07-03T22:08:00.838459+00:00 app[web.1]:   Rendered     static_pages/home.html.erb within layouts/application (1.0ms)
2016-07-03T22:08:00.843661+00:00 app[web.1]: ActionView::Template::Error     (Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html],     :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}.     Searched in:
2016-07-03T22:08:00.843667+00:00 app[web.1]:      7:   <%= csrf_meta_tags %>
2016-07-03T22:08:00.843669+00:00 app[web.1]:      8:   <%= render     "layouts/shim" %>
2016-07-03T22:08:00.843669+00:00 app[web.1]:      9: </head>
2016-07-03T22:08:00.843666+00:00 app[web.1]:      6:   <%=     javascript_include_tag 'application', 'data-turbolinks-track' => true %>
2016-07-03T22:08:00.843673+00:00 app[web.1]: 
2016-07-03T22:08:00.843672+00:00 app[web.1]:       app/views/layouts/application.html.erb:8:in     `_app_views_layouts_application_html_erb___1308690014084623887_70181780339020'
2016-07-03T22:08:00.843673+00:00 app[web.1]: 
2016-07-03T22:08:00.843670+00:00 app[web.1]:     10: <body>
2016-07-03T22:08:00.843671+00:00 app[web.1]:     11:   <%= render     'layouts/header' %>
2016-07-03T22:08:00.865455+00:00 heroku[router]: at=info method=GET      path="/favicon.ico" host=shielded-ocean-69345.herokuapp.com request_id=4d3005d1-     72e7-4f9d-bb0a-daef11fcb7d3 fwd="96.250.10.105" dyno=web.1 connect=0ms service=3ms      status=304 bytes=48
2016-07-03T22:12:19.033956+00:00 heroku[slug-compiler]: Slug compilation     started
2016-07-03T22:12:19.033964+00:00 heroku[slug-compiler]: Slug compilation     failed: failed to compile Ruby app
2016-07-03T22:13:49.911337+00:00 heroku[slug-compiler]: Slug compilation     failed: failed to compile Ruby app
2016-07-03T22:13:49.911326+00:00 heroku[slug-compiler]: Slug compilation     started
2016-07-03T22:14:53.615406+00:00 heroku[slug-compiler]: Slug compilation finished
2016-07-03T22:14:53.615398+00:00 heroku[slug-compiler]: Slug compilation started
2016-07-03T22:14:53.441497+00:00 heroku[api]: Release v9 created by     
2016-07-03T22:14:53.441423+00:00 heroku[api]: Deploy a287285 by 
2016-07-03T22:14:53.700320+00:00 heroku[web.1]: Restarting
2016-07-03T22:14:57.223797+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-07-03T22:14:57.232743+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 15046 -e production`
2016-07-03T22:14:58.065862+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2016-07-03T22:14:58.066171+00:00 app[web.1]: === puma shutdown: 2016-07-03 22:14:58 +0000 ===
2016-07-03T22:14:58.066206+00:00 app[web.1]: - Goodbye!
2016-07-03T22:14:58.066269+00:00 app[web.1]: Exiting
2016-07-03T22:14:59.302443+00:00 heroku[web.1]: Process exited with status 0
2016-07-03T22:15:01.107923+00:00 app[web.1]: => Booting Puma
2016-07-03T22:15:01.107985+00:00 app[web.1]: => Rails 4.2.2 application starting in production on http://0.0.0.0:15046
2016-07-03T22:15:01.107999+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-07-03T22:15:01.107995+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-07-03T22:15:01.691975+00:00 app[web.1]: Puma starting in single mode...
2016-07-03T22:15:01.691991+00:00 app[web.1]: * Version 3.1.0 (ruby 2.2.4-p230), codename: El Niño Winter Wonderland
2016-07-03T22:15:01.691993+00:00 app[web.1]: * Min threads: 0, max threads: 16
2016-07-03T22:15:01.691994+00:00 app[web.1]: * Environment: production
2016-07-03T22:15:01.692097+00:00 app[web.1]: * Listening on  tcp://0.0.0.0:15046
2016-07-03T22:15:01.692333+00:00 app[web.1]: Use Ctrl-C to stop
2016-07-03T22:15:11.972090+00:00 app[web.1]: ActionView::Template::Error  (Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
2016-07-03T22:15:11.969112+00:00 app[web.1]:   Rendered static_pages/home.html.erb within layouts/application (1.5ms)
2016-07-03T22:15:11.971214+00:00 app[web.1]: Completed 500 Internal Server Error in 20ms (ActiveRecord: 0.0ms)
2016-07-03T22:15:11.911510+00:00 app[web.1]: Started GET "/" for 96.250.10.105 at 2016-07-03 22:15:11 +0000
2016-07-03T22:15:11.951234+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-07-03T22:15:11.972091+00:00 app[web.1]:   * "/app/app/views"
2016-07-03T22:15:11.972092+00:00 app[web.1]: ):
2016-07-03T22:15:11.972080+00:00 app[web.1]: 
2016-07-03T22:15:11.972093+00:00 app[web.1]:      5:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
2016-07-03T22:15:11.972096+00:00 app[web.1]:      9: </head>
2016-07-03T22:15:11.972097+00:00 app[web.1]:     10: <body>
2016-07-03T22:15:11.972098+00:00 app[web.1]:   app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb___1593092074937796530_70210269730920'
2016-07-03T22:15:11.972099+00:00 app[web.1]: 
2016-07-03T22:15:11.972097+00:00 app[web.1]:     11:   <%= render 'layouts/header' %>
2016-07-03T22:15:11.972094+00:00 app[web.1]:      6:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
2016-07-03T22:15:11.972094+00:00 app[web.1]:      7:   <%= csrf_meta_tags %>
2016-07-03T22:15:11.972095+00:00 app[web.1]:      8:   <%= render "layouts/shim" %>
2016-07-03T22:15:11.972100+00:00 app[web.1]: 
2016-07-03T22:15:11.999714+00:00 heroku[router]: at=info method=GET path="/" host=shielded-ocean-69345.herokuapp.com request_id=43050116-0f99-423b-88f1-46d62700857f fwd="96.250.10.105" dyno=web.1 connect=0ms service=66ms status=500 bytes=1669
2016-07-03T22:15:12.052653+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=shielded-ocean-69345.herokuapp.com request_id=6ffdd04c-53c8-4383-a095-1d34f0ab155c fwd="96.250.10.105" dyno=web.1 connect=0ms service=2ms status=200 bytes=143
2016-07-03T22:16:19.702633+00:00 heroku[router]: at=info method=GET path="/" host=shielded-ocean-69345.herokuapp.com request_id=75bbacb3-3bd6-4d49-877f-1d8155eb5ba8 fwd="96.250.10.105" dyno=web.1 connect=1ms service=8ms status=500 bytes=1669
2016-07-03T22:16:19.696865+00:00 app[web.1]: Started GET "/" for 96.250.10.105     at 2016-07-03 22:16:19 +0000
2016-07-03T22:16:19.698826+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-07-03T22:16:19.700097+00:00 app[web.1]:   Rendered static_pages/home.html.erb within layouts/application (0.5ms)
2016-07-03T22:16:19.704512+00:00 app[web.1]: 
2016-07-03T22:16:19.704537+00:00 app[web.1]: ActionView::Template::Error (Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
2016-07-03T22:16:19.704540+00:00 app[web.1]:   * "/app/app/views"
2016-07-03T22:16:19.704540+00:00 app[web.1]: ):
2016-07-03T22:16:19.704541+00:00 app[web.1]:      5:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
2016-07-03T22:16:19.701766+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
2016-07-03T22:16:19.704543+00:00 app[web.1]:      7:   <%= csrf_meta_tags %>
2016-07-03T22:16:19.704542+00:00 app[web.1]:      6:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
2016-07-03T22:16:19.704545+00:00 app[web.1]:      9: </head>
2016-07-03T22:16:19.704544+00:00 app[web.1]:      8:   <%= render "layouts/shim" %>
2016-07-03T22:16:19.704545+00:00 app[web.1]:     10: <body>
2016-07-03T22:16:19.704546+00:00 app[web.1]:     11:   <%= render 'layouts/header' %>
2016-07-03T22:16:19.704548+00:00 app[web.1]: 
2016-07-03T22:16:19.704547+00:00 app[web.1]:   app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb___1593092074937796530_70210269730920'
2016-07-03T22:16:19.704548+00:00 app[web.1]: 
2016-07-03T22:16:19.758932+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=shielded-ocean-69345.herokuapp.com request_id=66c5443b-55f1-4d26-a231-f68b68fa32e0 fwd="96.250.10.105" dyno=web.1 connect=1ms service=2ms status=304 bytes=48

以下是我的application.html.erb文件的內容:

<!DOCTYPE html>
<html>
<head>
   <title><%= full_title(yield(:title)) %></title>
   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-   track' => true %>
   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
   <%= csrf_meta_tags %>
   <%= render 'layouts/shim' %>
 </head>
 <body>
    <%= render 'layouts/header' %>
    <div class="container">
       <%= yield %>
       <%= render "layouts/footer" %>
    </div>
</body>
</html>

以下是被引用的_shim文件的內容:

<!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html15.min.js">
    </script>
<![endif]-->

我知道這是一團糟,但通過查看我不確定是什么問題。 我希望有經驗的人能夠為我指出正確的方向。

謝謝

這是錯誤:

ActionView::Template::Error (Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:

您在主布局中缺少填充部分,請創建在主布局文件中調用的填充部分。

從日志看來,您似乎缺少或錯位了部分墊片,因為該應用無法找到它。 在Rails中,部分文件的名稱以下划線開頭,如下所示:'_shim.html.erb'

部署到heroku之前,請按以下方式更新application.html.erb文件:

<!DOCTYPE html>
<html>
  <head>
    <title><%= full_title(yield(:title)) %></title>
    <%= render 'layouts/rails_default' %>
    <%= render 'layouts/shim' %>
  </head>
  <body>
    <%= render 'layouts/header' %>
    <div class="container">
      <%= yield %>
      <%= render 'layouts/footer' %>
    </div>
  </body>
</html>

盡管該應用程序在本地運行(在cloud9上),但我在Heroku上也遇到了相同的錯誤消息。 事實證明,由於我將git commit -am 'message'限制為git commit -am 'message' ,因此Heroku找不到該文件。 結果,我沒有提交任何新創建的文件( git commit -am僅提交修改的文件,而不提交新創建的文件)。 嘗試運行git add . 然后提交。 這應該允許Heroku“查看”丟失的文件。

回答您的問題可能為時已晚,但希望這可以幫助某人像我一樣尋找此問題的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM