Rails应用程序在本地运行,但在Heroku

时间:2016-07-03 22:49:26

标签: ruby-on-rails ruby ruby-on-rails-4 heroku railstutorial.org

我一直在关注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]-->

我知道这很乱,但看看这个我不知道是什么问题。我希望有经验的人能指出我正确的方向。

谢谢

4 个答案:

答案 0 :(得分:2)

这是错误:

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

您在主布局中缺少shim partial,在主布局文件中调用shim partial。

答案 1 :(得分:1)

从日志中看起来你错过了或者错误放置了你的垫片部分,因为应用程序找不到它。在Rails中,partials的文件名以下划线开头,如下所示:'_ shim.html.erb'

答案 2 :(得分:0)

请在部署到heroku之前更新您的application.html.erb文件,如下所示:

Enter

答案 3 :(得分:0)

尽管该应用程序在本地运行(在cloud9上),但在Heroku上我仍然遇到相同的错误消息。事实证明,由于我将git commit限制为git commit -am 'message',因此Heroku找不到该文件。结果,我没有提交任何新创建的文件(git commit -am仅提交已修改的文件,而不提交新创建的文件)。尝试运行git add .,然后提交。这应该允许Heroku“查看”丢失的文件。

回答您的问题可能为时已晚,但希望这可以帮助某人像我一样寻找该问题的答案。