Hartl 教程 3.1:导航到 'home' 静态页面时出现 500 运行时错误
Hartl Tutorial 3.1: 500 Runtime Error when navigating to 'home' static page
总的来说,我对编码非常陌生 - 所以要温和。
我在第 3 章 3.1,在创建 static_pages
、主页和帮助后的最后,通过输入 $ rails generate controller StaticPages home help
,我无法在没有相应的页面的情况下导航到该页面500 运行时错误,进而 Killed
运行ning 服务器。
"hello" 应用程序工作正常,到目前为止我没有遇到任何问题。
注意:我在 Windows 7 x64 上学习教程,但我采纳了 Hartl 的建议,将 Cloud IDE 与 Git、Bitbucket 和 Heroku 一起使用。我确实必须 运行 Rails 4.2.1 而不是 Rails 4.2.2 但是由于第一次启动时出现问题。
我做错了什么?如果我需要包含更多信息,请告诉我,这对我来说都是全新的。
编辑:
我再次检查了我的文件,正如@Rich Peck 所说的那样,它们都是一样的,除了 Routes.rb
文件只有这个(由系统生成,我也省略了所有 # 注释):
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
root 'application#hello'
end
我也按照一些评论的说法提取了我的日志,这是最后 100 行的结果:
2015-10-11T21:25:49.589384+00:00 app[web.1]: => Run
rails server -hfor more startup options
2015-10-11T21:25:49.589385+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T21:25:49.589386+00:00 app[web.1]: Started GET "/" for 208.115.151.20 at 2015-10-11 21:25:49 +0000
2015-10-11T21:25:49.646987+00:00 app[web.1]: Processing by ApplicationController#hello as HTML
2015-10-11T21:25:49.656139+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 0.8ms | ActiveRecord: 0.0ms)
2015-10-11T21:25:49.655832+00:00 app[web.1]: Rendered text template (0.0ms)
2015-10-11T21:25:49.786454+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-journey-1439.herokuapp.com request_id=2474855b-e5c5-4db8-8b2a-83f0d6095d2d fwd="208.115.151.20" dyno=web.1 connect=0ms service=3ms status=200 bytes=228
2015-10-11T21:25:49.658965+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-journey-1439.herokuapp.com request_id=e85687fc-6820-42c1-b389-4a6d8e0e2ffa fwd="208.115.151.20" dyno=web.1 connect=0ms service=73ms status=304 bytes=397
2015-10-11T21:59:04.638018+00:00 heroku[web.1]: Idling
2015-10-11T21:59:04.638730+00:00 heroku[web.1]: State changed from up to down
2015-10-11T21:59:04.639573+00:00 heroku[web.1]: State changed from down to starting
2015-10-11T21:59:06.575098+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T21:59:06.991420+00:00 app[web.1]: [2015-10-11 21:59:06] FATAL SignalException: SIGTERM
2015-10-11T21:59:06.991427+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T21:59:06.991429+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T21:59:06.991431+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T21:59:06.991432+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T21:59:06.991433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T21:59:06.991434+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in start'
2015-10-11T21:59:06.991436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in
开始'
2015-10-11T21:59:06.991438+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in block in server'
2015-10-11T21:59:06.991440+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T21:59:06.991441+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T21:59:06.991442+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in
run_command!'
2015-10-11T21:59:06.991443+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T21:59:06.991445+00:00 app[web.1]: bin/rails:8:in
要求'
2015-10-11T21:59:06.991446+00:00 app[web.1]: bin/rails:8:in <main>'
2015-10-11T21:59:06.991478+00:00 app[web.1]: [2015-10-11 21:59:06] INFO WEBrick::HTTPServer#start done.
2015-10-11T21:59:06.991452+00:00 app[web.1]: [2015-10-11 21:59:06] INFO going to shutdown ...
2015-10-11T21:59:06.991498+00:00 app[web.1]: Exiting
2015-10-11T21:59:07.767999+00:00 heroku[web.1]: Process exited with status 143
2015-10-11T21:59:08.554265+00:00 heroku[web.1]: Starting process with command
bin/rails server -p 21794 -e production
2015-10-11T21:59:12.579369+00:00 app[web.1]: [2015-10-11 21:59:12] INFO WEBrick 1.3.1
2015-10-11T21:59:12.579406+00:00 app[web.1]: [2015-10-11 21:59:12] INFO ruby 2.0.0 (2015-04-13) [x86_64-linux]
2015-10-11T21:59:12.579784+00:00 app[web.1]: [2015-10-11 21:59:12] INFO WEBrick::HTTPServer#start: pid=3 port=21794
2015-10-11T21:59:13.087410+00:00 heroku[web.1]: State changed from starting to up
2015-10-11T22:34:07.204262+00:00 heroku[web.1]: Idling
2015-10-11T22:34:07.204981+00:00 heroku[web.1]: State changed from up to down
2015-10-11T22:34:10.871115+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T22:34:11.813473+00:00 app[web.1]: [2015-10-11 22:34:11] FATAL SignalException: SIGTERM
2015-10-11T22:34:11.813479+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T22:34:11.813483+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T22:34:11.813484+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T22:34:11.813486+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T22:34:11.813487+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T22:34:11.813489+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in start'
2015-10-11T22:34:11.813490+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in
开始'
2015-10-11T22:34:11.813492+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in block in server'
2015-10-11T22:34:11.813493+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T22:34:11.813495+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T22:34:11.813497+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in
run_command!'
2015-10-11T22:34:11.813498+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T22:34:11.813500+00:00 app[web.1]: bin/rails:8:in
要求'
2015-10-11T22:34:11.813501+00:00 app[web.1]: bin/rails:8:in <main>'
2015-10-11T22:34:11.813508+00:00 app[web.1]: [2015-10-11 22:34:11] INFO going to shutdown ...
2015-10-11T22:34:11.813551+00:00 app[web.1]: [2015-10-11 22:34:11] INFO WEBrick::HTTPServer#start done.
2015-10-11T22:34:11.813591+00:00 app[web.1]: => Booting WEBrick
2015-10-11T22:34:11.813594+00:00 app[web.1]: => Run
rails 服务器-hfor more startup options
2015-10-11T22:34:11.813593+00:00 app[web.1]: => Rails 4.2.1 application starting in production on http://0.0.0.0:21794
2015-10-11T22:34:11.813598+00:00 app[web.1]: Exiting
2015-10-11T22:34:11.813596+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T22:34:12.863144+00:00 heroku[web.1]: Process exited with status 143
2015-10-11T22:59:27.859347+00:00 heroku[web.1]: Unidling
2015-10-11T22:59:27.859754+00:00 heroku[web.1]: State changed from down to starting
2015-10-11T22:59:31.767799+00:00 heroku[web.1]: Starting process with command
bin/rails server -p 43789 -e production
2015-10-11T22:59:35.850425+00:00 app[web.1]: [2015-10-11 22:59:35] INFO WEBrick 1.3.1
2015-10-11T22:59:35.850445+00:00 app[web.1]: [2015-10-11 22:59:35] INFO ruby 2.0.0 (2015-04-13) [x86_64-linux]
2015-10-11T22:59:35.850845+00:00 app[web.1]: [2015-10-11 22:59:35] INFO WEBrick::HTTPServer#start: pid=3 port=43789
2015-10-11T22:59:36.187808+00:00 heroku[web.1]: State changed from starting to up
2015-10-11T22:59:36.930155+00:00 app[web.1]: => Booting WEBrick
2015-10-11T22:59:36.930162+00:00 app[web.1]: => Rails 4.2.1 application starting in production on http://0.0.0.0:43789
2015-10-11T22:59:36.930163+00:00 app[web.1]: => Run
rails server -hfor more startup options
2015-10-11T22:59:36.930165+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T22:59:36.963421+00:00 app[web.1]: Processing by ApplicationController#hello as HTML
2015-10-11T22:59:36.930166+00:00 app[web.1]: Started GET "/" for 208.115.151.20 at 2015-10-11 22:59:36 +0000
2015-10-11T22:59:36.971478+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 0.6ms | ActiveRecord: 0.0ms)
2015-10-11T22:59:36.974594+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-journey-1439.herokuapp.com request_id=b8fe0c84-e45c-4997-be06-9742f276fb98 fwd="208.115.151.20" dyno=web.1 connect=1ms service=47ms status=304 bytes=397
2015-10-11T22:59:36.971195+00:00 app[web.1]: Rendered text template (0.0ms)
2015-10-11T22:59:37.155800+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-journey-1439.herokuapp.com request_id=ce175e20-0e6c-40e1-9e4e-ec842143c159 fwd="208.115.151.20" dyno=web.1 connect=16ms service=4ms status=200 bytes=228
2015-10-11T23:35:06.014571+00:00 heroku[web.1]: Idling
2015-10-11T23:35:06.015165+00:00 heroku[web.1]: State changed from up to down
2015-10-11T23:35:08.748838+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T23:35:09.396823+00:00 app[web.1]: [2015-10-11 23:35:09] FATAL SignalException: SIGTERM
2015-10-11T23:35:09.396829+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T23:35:09.396831+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T23:35:09.396833+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T23:35:09.396834+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T23:35:09.396835+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T23:35:09.396838+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:在start'
2015-10-11T23:35:09.396836+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in
开始'
2015-10-11T23:35:09.396843+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in run_command!'
2015-10-11T23:35:09.396840+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in
在服务器中阻止'
2015-10-11T23:35:09.396846+00:00 app[web.1]: bin/rails:8:in require'
2015-10-11T23:35:09.396847+00:00 app[web.1]: bin/rails:8:in
'
2015-10-11T23:35:09.396842+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T23:35:09.396841+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T23:35:09.396844+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T23:35:09.396853+00:00 app[web.1]: [2015-10-11 23:35:09] INFO going to shutdown ...
2015-10-11T23:35:09.396894+00:00 app[web.1]: Exiting
2015-10-11T23:35:09.396870+00:00 app[web.1]: [2015-10-11 23:35:09] INFO WEBrick::HTTPServer#start done.
2015-10-11T23:35:10.254851+00:00 heroku[web.1]: Process exited with status 143
WARNING: Toolbelt v3.42.17 update available.
I'm extremely new to coding
因为您是新手,所以我将向您详细说明如何调试。它本身可能不是一个答案,但它至少应该能帮助你。
首先,您需要确保 controller
和 views
设置正确。
许多新编码员的主要问题是他们会盲目地遵循教程,然后无法理解正在做什么。我知道那是什么感觉,因为我一直这样做(在学习新东西时)..
因此,您需要了解什么被添加到您的应用程序,以及它应该如何表现:
1.控制器
您的第一个停靠点是 控制器。
Rails 将创建:
#app/controllers/static_pages_controller.rb
class StaticPagesController < ApplicationController
def hello
end
def help
end
end
虽然没有严格遵守您稍后将在 Rails 中使用的 CRUD
设置,但至少应该让您能够调用这两个操作。
您必须先检查您是否有上述文件。
2。观看次数
其次,您需要查看您产生的浏览量。
这些将位于:
#app/views/static_pages/hello.html.erb
#app/views/static_pages/help.html.erb
这两个都将提供允许您查看您的控制器操作输出的功能。目前它们对调试过程并不重要。
他们真的应该什么都没有。
3。路线
最后,你想看看你的路线。
#config/routes.rb
resources :static_pages, only: [], path: "" do
collection do
get :hello #-> url.com/hello
get :help #-> url.com/help
end
end
这将使您能够访问控制器操作,并因此能够访问您刚刚生成的视图。
所有这些都应该协同工作,无需任何数据,以提供对 url.com/hello
和 url.com/help
.
的访问
(来源:asciicasts.com)
500 Errors 基本上是说您的 服务器 有错误。
服务器上的哪些错误可能导致 500 问题?
主要是调用了不存在的变量...
#app/views/static_pages/hello.html.erb
<%= @hello %>
如果您正在使用 Heroku
,最好的调试方法(与标准 Rails 一样)是查看控制台。在标准 rails 中,控制台在您的屏幕上可见(大部分时间);对于 Heroku,它略有不同。
Heroku 日志很奇怪,因为它们在 Windows 中的格式不是很好。我们倾向于使用 LogEntries
和 "live" 功能来查看发生了什么,并纠正它:
浏览这些日志会告诉您错误是什么,从而让您对如何修复它有一些看法。
--
最后,您可能希望使用 gem 例如 better_errors
or exception_handler
总的来说,我对编码非常陌生 - 所以要温和。
我在第 3 章 3.1,在创建 static_pages
、主页和帮助后的最后,通过输入 $ rails generate controller StaticPages home help
,我无法在没有相应的页面的情况下导航到该页面500 运行时错误,进而 Killed
运行ning 服务器。
"hello" 应用程序工作正常,到目前为止我没有遇到任何问题。
注意:我在 Windows 7 x64 上学习教程,但我采纳了 Hartl 的建议,将 Cloud IDE 与 Git、Bitbucket 和 Heroku 一起使用。我确实必须 运行 Rails 4.2.1 而不是 Rails 4.2.2 但是由于第一次启动时出现问题。
我做错了什么?如果我需要包含更多信息,请告诉我,这对我来说都是全新的。
编辑:
我再次检查了我的文件,正如@Rich Peck 所说的那样,它们都是一样的,除了 Routes.rb
文件只有这个(由系统生成,我也省略了所有 # 注释):
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
root 'application#hello'
end
我也按照一些评论的说法提取了我的日志,这是最后 100 行的结果:
2015-10-11T21:25:49.589384+00:00 app[web.1]: => Run
rails server -hfor more startup options
2015-10-11T21:25:49.589385+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T21:25:49.589386+00:00 app[web.1]: Started GET "/" for 208.115.151.20 at 2015-10-11 21:25:49 +0000
2015-10-11T21:25:49.646987+00:00 app[web.1]: Processing by ApplicationController#hello as HTML
2015-10-11T21:25:49.656139+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 0.8ms | ActiveRecord: 0.0ms)
2015-10-11T21:25:49.655832+00:00 app[web.1]: Rendered text template (0.0ms)
2015-10-11T21:25:49.786454+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-journey-1439.herokuapp.com request_id=2474855b-e5c5-4db8-8b2a-83f0d6095d2d fwd="208.115.151.20" dyno=web.1 connect=0ms service=3ms status=200 bytes=228
2015-10-11T21:25:49.658965+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-journey-1439.herokuapp.com request_id=e85687fc-6820-42c1-b389-4a6d8e0e2ffa fwd="208.115.151.20" dyno=web.1 connect=0ms service=73ms status=304 bytes=397
2015-10-11T21:59:04.638018+00:00 heroku[web.1]: Idling
2015-10-11T21:59:04.638730+00:00 heroku[web.1]: State changed from up to down
2015-10-11T21:59:04.639573+00:00 heroku[web.1]: State changed from down to starting
2015-10-11T21:59:06.575098+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T21:59:06.991420+00:00 app[web.1]: [2015-10-11 21:59:06] FATAL SignalException: SIGTERM
2015-10-11T21:59:06.991427+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T21:59:06.991429+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T21:59:06.991431+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T21:59:06.991432+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T21:59:06.991433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T21:59:06.991434+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in start'
2015-10-11T21:59:06.991436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in
开始'
2015-10-11T21:59:06.991438+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in block in server'
2015-10-11T21:59:06.991440+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T21:59:06.991441+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T21:59:06.991442+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in
run_command!'
2015-10-11T21:59:06.991443+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T21:59:06.991445+00:00 app[web.1]: bin/rails:8:in
要求'
2015-10-11T21:59:06.991446+00:00 app[web.1]: bin/rails:8:in <main>'
2015-10-11T21:59:06.991478+00:00 app[web.1]: [2015-10-11 21:59:06] INFO WEBrick::HTTPServer#start done.
2015-10-11T21:59:06.991452+00:00 app[web.1]: [2015-10-11 21:59:06] INFO going to shutdown ...
2015-10-11T21:59:06.991498+00:00 app[web.1]: Exiting
2015-10-11T21:59:07.767999+00:00 heroku[web.1]: Process exited with status 143
2015-10-11T21:59:08.554265+00:00 heroku[web.1]: Starting process with command
bin/rails server -p 21794 -e production
2015-10-11T21:59:12.579369+00:00 app[web.1]: [2015-10-11 21:59:12] INFO WEBrick 1.3.1
2015-10-11T21:59:12.579406+00:00 app[web.1]: [2015-10-11 21:59:12] INFO ruby 2.0.0 (2015-04-13) [x86_64-linux]
2015-10-11T21:59:12.579784+00:00 app[web.1]: [2015-10-11 21:59:12] INFO WEBrick::HTTPServer#start: pid=3 port=21794
2015-10-11T21:59:13.087410+00:00 heroku[web.1]: State changed from starting to up
2015-10-11T22:34:07.204262+00:00 heroku[web.1]: Idling
2015-10-11T22:34:07.204981+00:00 heroku[web.1]: State changed from up to down
2015-10-11T22:34:10.871115+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T22:34:11.813473+00:00 app[web.1]: [2015-10-11 22:34:11] FATAL SignalException: SIGTERM
2015-10-11T22:34:11.813479+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T22:34:11.813483+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T22:34:11.813484+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T22:34:11.813486+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T22:34:11.813487+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T22:34:11.813489+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in start'
2015-10-11T22:34:11.813490+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in
开始'
2015-10-11T22:34:11.813492+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in block in server'
2015-10-11T22:34:11.813493+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T22:34:11.813495+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T22:34:11.813497+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in
run_command!'
2015-10-11T22:34:11.813498+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T22:34:11.813500+00:00 app[web.1]: bin/rails:8:in
要求'
2015-10-11T22:34:11.813501+00:00 app[web.1]: bin/rails:8:in <main>'
2015-10-11T22:34:11.813508+00:00 app[web.1]: [2015-10-11 22:34:11] INFO going to shutdown ...
2015-10-11T22:34:11.813551+00:00 app[web.1]: [2015-10-11 22:34:11] INFO WEBrick::HTTPServer#start done.
2015-10-11T22:34:11.813591+00:00 app[web.1]: => Booting WEBrick
2015-10-11T22:34:11.813594+00:00 app[web.1]: => Run
rails 服务器-hfor more startup options
2015-10-11T22:34:11.813593+00:00 app[web.1]: => Rails 4.2.1 application starting in production on http://0.0.0.0:21794
2015-10-11T22:34:11.813598+00:00 app[web.1]: Exiting
2015-10-11T22:34:11.813596+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T22:34:12.863144+00:00 heroku[web.1]: Process exited with status 143
2015-10-11T22:59:27.859347+00:00 heroku[web.1]: Unidling
2015-10-11T22:59:27.859754+00:00 heroku[web.1]: State changed from down to starting
2015-10-11T22:59:31.767799+00:00 heroku[web.1]: Starting process with command
bin/rails server -p 43789 -e production
2015-10-11T22:59:35.850425+00:00 app[web.1]: [2015-10-11 22:59:35] INFO WEBrick 1.3.1
2015-10-11T22:59:35.850445+00:00 app[web.1]: [2015-10-11 22:59:35] INFO ruby 2.0.0 (2015-04-13) [x86_64-linux]
2015-10-11T22:59:35.850845+00:00 app[web.1]: [2015-10-11 22:59:35] INFO WEBrick::HTTPServer#start: pid=3 port=43789
2015-10-11T22:59:36.187808+00:00 heroku[web.1]: State changed from starting to up
2015-10-11T22:59:36.930155+00:00 app[web.1]: => Booting WEBrick
2015-10-11T22:59:36.930162+00:00 app[web.1]: => Rails 4.2.1 application starting in production on http://0.0.0.0:43789
2015-10-11T22:59:36.930163+00:00 app[web.1]: => Run
rails server -hfor more startup options
2015-10-11T22:59:36.930165+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-10-11T22:59:36.963421+00:00 app[web.1]: Processing by ApplicationController#hello as HTML
2015-10-11T22:59:36.930166+00:00 app[web.1]: Started GET "/" for 208.115.151.20 at 2015-10-11 22:59:36 +0000
2015-10-11T22:59:36.971478+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 0.6ms | ActiveRecord: 0.0ms)
2015-10-11T22:59:36.974594+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-journey-1439.herokuapp.com request_id=b8fe0c84-e45c-4997-be06-9742f276fb98 fwd="208.115.151.20" dyno=web.1 connect=1ms service=47ms status=304 bytes=397
2015-10-11T22:59:36.971195+00:00 app[web.1]: Rendered text template (0.0ms)
2015-10-11T22:59:37.155800+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-journey-1439.herokuapp.com request_id=ce175e20-0e6c-40e1-9e4e-ec842143c159 fwd="208.115.151.20" dyno=web.1 connect=16ms service=4ms status=200 bytes=228
2015-10-11T23:35:06.014571+00:00 heroku[web.1]: Idling
2015-10-11T23:35:06.015165+00:00 heroku[web.1]: State changed from up to down
2015-10-11T23:35:08.748838+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-11T23:35:09.396823+00:00 app[web.1]: [2015-10-11 23:35:09] FATAL SignalException: SIGTERM
2015-10-11T23:35:09.396829+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in
select'
2015-10-11T23:35:09.396831+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in block in start'
2015-10-11T23:35:09.396833+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in
开始'
2015-10-11T23:35:09.396834+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in start'
2015-10-11T23:35:09.396835+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in
运行'
2015-10-11T23:35:09.396838+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:在start'
2015-10-11T23:35:09.396836+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:286:in
开始'
2015-10-11T23:35:09.396843+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in run_command!'
2015-10-11T23:35:09.396840+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in
在服务器中阻止'
2015-10-11T23:35:09.396846+00:00 app[web.1]: bin/rails:8:in require'
2015-10-11T23:35:09.396847+00:00 app[web.1]: bin/rails:8:in
'
2015-10-11T23:35:09.396842+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server'
2015-10-11T23:35:09.396841+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in
点击'
2015-10-11T23:35:09.396844+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>'
2015-10-11T23:35:09.396853+00:00 app[web.1]: [2015-10-11 23:35:09] INFO going to shutdown ...
2015-10-11T23:35:09.396894+00:00 app[web.1]: Exiting
2015-10-11T23:35:09.396870+00:00 app[web.1]: [2015-10-11 23:35:09] INFO WEBrick::HTTPServer#start done.
2015-10-11T23:35:10.254851+00:00 heroku[web.1]: Process exited with status 143
WARNING: Toolbelt v3.42.17 update available.
I'm extremely new to coding
因为您是新手,所以我将向您详细说明如何调试。它本身可能不是一个答案,但它至少应该能帮助你。
首先,您需要确保 controller
和 views
设置正确。
许多新编码员的主要问题是他们会盲目地遵循教程,然后无法理解正在做什么。我知道那是什么感觉,因为我一直这样做(在学习新东西时)..
因此,您需要了解什么被添加到您的应用程序,以及它应该如何表现:
1.控制器
您的第一个停靠点是 控制器。
Rails 将创建:
#app/controllers/static_pages_controller.rb
class StaticPagesController < ApplicationController
def hello
end
def help
end
end
虽然没有严格遵守您稍后将在 Rails 中使用的 CRUD
设置,但至少应该让您能够调用这两个操作。
您必须先检查您是否有上述文件。
2。观看次数
其次,您需要查看您产生的浏览量。
这些将位于:
#app/views/static_pages/hello.html.erb
#app/views/static_pages/help.html.erb
这两个都将提供允许您查看您的控制器操作输出的功能。目前它们对调试过程并不重要。
他们真的应该什么都没有。
3。路线
最后,你想看看你的路线。
#config/routes.rb
resources :static_pages, only: [], path: "" do
collection do
get :hello #-> url.com/hello
get :help #-> url.com/help
end
end
这将使您能够访问控制器操作,并因此能够访问您刚刚生成的视图。
所有这些都应该协同工作,无需任何数据,以提供对 url.com/hello
和 url.com/help
.
(来源:asciicasts.com)
500 Errors 基本上是说您的 服务器 有错误。
服务器上的哪些错误可能导致 500 问题?
主要是调用了不存在的变量...
#app/views/static_pages/hello.html.erb
<%= @hello %>
如果您正在使用 Heroku
,最好的调试方法(与标准 Rails 一样)是查看控制台。在标准 rails 中,控制台在您的屏幕上可见(大部分时间);对于 Heroku,它略有不同。
Heroku 日志很奇怪,因为它们在 Windows 中的格式不是很好。我们倾向于使用 LogEntries
和 "live" 功能来查看发生了什么,并纠正它:
浏览这些日志会告诉您错误是什么,从而让您对如何修复它有一些看法。
--
最后,您可能希望使用 gem 例如 better_errors
or exception_handler