我的Rails 4应用程序在我的本地计算机上运行完美,但是当我部署到Heroku时,我收到了一个应用程序错误。即使Heroku说部署成功,也会发生错误。错误消息的文本是:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
要解决问题,我在控制台中运行了“heroku logs”,生成了以下内容:
2015-06-18T00:42:56.355811+00:00 heroku[api]: Release v84 created by xxxxx@xxxxx.com
2015-06-18T00:42:56.418446+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-18T00:42:56.418465+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-18T00:42:57.437719+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-18T00:43:02.751137+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 58907 -c ./config/unicorn.rb`
2015-06-18T00:43:06.428523+00:00 app[web.1]: I, [2015-06-18T00:43:06.428375 #3] INFO -- : Refreshing Gem list
2015-06-18T00:43:08.143475+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require': /app/app/helpers/simple_form.rb:5: syntax error, unexpected ')', expecting => (SyntaxError)
2015-06-18T00:43:08.143482+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
2015-06-18T00:43:08.143486+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
2015-06-18T00:43:08.143484+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
2015-06-18T00:43:08.143487+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:348:in `require_or_load'
2015-06-18T00:43:08.143491+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:307:in `depend_on'
2015-06-18T00:43:08.143492+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:225:in `require_dependency'
2015-06-18T00:43:08.143493+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:468:in `block (2 levels) in eager_load!'
2015-06-18T00:43:08.143497+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:467:in `each'
2015-06-18T00:43:08.143499+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:467:in `block in eager_load!'
2015-06-18T00:43:08.143502+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:465:in `each'
2015-06-18T00:43:08.143504+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:465:in `eager_load!'
2015-06-18T00:43:08.143507+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:346:in `eager_load!'
2015-06-18T00:43:08.143509+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:58:in `each'
2015-06-18T00:43:08.143512+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>'
2015-06-18T00:43:08.143513+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec'
2015-06-18T00:43:08.143517+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run'
2015-06-18T00:43:08.143520+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
2015-06-18T00:43:08.143522+00:00 app[web.1]: from /app/vendor/ruby- 2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
2015-06-18T00:43:08.143531+00:00 app[web.1]: from /app/vendor/ruby- 2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
2015-06-18T00:43:08.143534+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
2015-06-18T00:43:08.143536+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
2015-06-18T00:43:08.143538+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
2015-06-18T00:43:08.143539+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
2015-06-18T00:43:08.143542+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
2015-06-18T00:43:08.143545+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!'
2015-06-18T00:43:08.143544+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers'
2015-06-18T00:43:08.143548+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2015-06-18T00:43:08.143550+00:00 app[web.1]: from config.ru:4:in `require'
2015-06-18T00:43:08.143554+00:00 app[web.1]: from config.ru:4:in `block in <main>'
2015-06-18T00:43:08.143555+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2015-06-18T00:43:08.143559+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2015-06-18T00:43:08.143561+00:00 app[web.1]: from config.ru:1:in `new'
2015-06-18T00:43:08.143564+00:00 app[web.1]: from config.ru:1:in `<main>'
2015-06-18T00:43:08.143572+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
2015-06-18T00:43:08.143569+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
2015-06-18T00:43:08.143574+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
2015-06-18T00:43:08.143577+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
2015-06-18T00:43:08.143588+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2015-06-18T00:43:08.143579+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'
2015-06-18T00:43:08.143583+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2015-06-18T00:43:08.143586+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2015-06-18T00:43:09.019077+00:00 heroku[web.1]: Process exited with status 1
2015-06-18T00:43:09.035754+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-18T00:43:09.037320+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-18T00:43:12.753943+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 44603 -c ./config/unicorn.rb`
2015-06-18T00:43:15.031204+00:00 app[web.1]: I, [2015-06-18T00:43:15.031071 #3] INFO -- : Refreshing Gem list
**2015-06-18T00:43:16.824808+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require': /app/app/helpers/simple_form.rb:5: syntax error, unexpected ')', expecting => (SyntaxError)**
2015-06-18T00:43:16.824815+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
2015-06-18T00:43:16.824818+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
2015-06-18T00:43:16.824822+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
2015-06-18T00:43:16.824825+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:348:in `require_or_load'
2015-06-18T00:43:16.824832+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:225:in `require_dependency'
2015-06-18T00:43:16.824853+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:468:in `block (2 levels) in eager_load!'
2015-06-18T00:43:16.824829+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:307:in `depend_on'
2015-06-18T00:43:16.824855+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:467:in `each'
2015-06-18T00:43:16.824859+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:467:in `block in eager_load!'
2015-06-18T00:43:16.824863+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:465:in `each'
2015-06-18T00:43:16.824864+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:465:in `eager_load!'
2015-06-18T00:43:16.824866+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:346:in `eager_load!'
2015-06-18T00:43:16.824867+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:58:in `each'
2015-06-18T00:43:16.824871+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>'
2015-06-18T00:43:16.824872+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec'
2015-06-18T00:43:16.824874+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run'
2015-06-18T00:43:16.824877+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
2015-06-18T00:43:16.824879+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
2015-06-18T00:43:16.824897+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
2015-06-18T00:43:16.824898+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
2015-06-18T00:43:16.824903+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
2015-06-18T00:43:16.824905+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
2015-06-18T00:43:16.824906+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
2015-06-18T00:43:16.824907+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
2015-06-18T00:43:16.824909+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers'
2015-06-18T00:43:16.824910+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!'
2015-06-18T00:43:16.824916+00:00 app[web.1]: from config.ru:4:in `require'
2015-06-18T00:43:16.824912+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2015-06-18T00:43:16.824917+00:00 app[web.1]: from config.ru:4:in `block in <main>'
2015-06-18T00:43:16.824919+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2015-06-18T00:43:16.824921+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2015-06-18T00:43:16.824923+00:00 app[web.1]: from config.ru:1:in `new'
2015-06-18T00:43:16.824926+00:00 app[web.1]: from config.ru:1:in `<main>'
2015-06-18T00:43:16.824927+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
2015-06-18T00:43:16.824929+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
2015-06-18T00:43:16.824930+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
2015-06-18T00:43:16.824935+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'
2015-06-18T00:43:16.824934+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
2015-06-18T00:43:16.824936+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2015-06-18T00:43:16.824940+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2015-06-18T00:43:16.824941+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2015-06-18T00:43:17.765684+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-18T00:43:17.751742+00:00 heroku[web.1]: Process exited with status 1
2015-06-18T00:43:18.999914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gym-app.herokuapp.com request_id=7fe8bc0d-7744-4b9a-a6af-841451c30b8f fwd="67.100.124.109" dyno= connect= service= status=503 bytes=
2015-06-18T00:43:40.236226+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gym-app.herokuapp.com request_id=54039c3e-c328-4ecd-b379-917fb5e33fec fwd="67.100.124.109" dyno= connect= service= status=503 bytes=
2015-06-18T00:44:26.777920+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gym-app.herokuapp.com request_id=7169af3e-6665-4c9c-9498-8695f31c6f78 fwd="67.100.124.109" dyno= connect= service= status=503 bytes=
2015-06-18T00:48:08.390055+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gym-app.herokuapp.com request_id=07bfbcef-38da-4d68-b5e4-6bf29e3816ae fwd="67.100.124.109" dyno= connect= service= status=503 bytes=
我不确定,但我想我已经确定了问题的根源。以下内容对我来说很突出:
2015-06-18T00:43:16.824808+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require': /app/app/helpers/simple_form.rb:5: syntax error, unexpected ')', expecting => (SyntaxError)
这是我的simple_form帮助文件的内容:
module SimpleForm
module Inputs
class DateTimePickerInput < Base
def input
@builder.text_field(attribute_name, :class => 'date_time_picker', input_html_options)
end
end
end
end
请注意,在编写帮助文件之前,我可以将应用程序成功部署到Heroku。似乎Heroku在我的语法上不知所措 - 特别是右括号。但是,我不知道如何纠正这个问题。我需要做些什么来满足Heroku?我很感激有助于我的应用程序再次成功部署。谢谢!
答案 0 :(得分:1)
只需替换:
@builder.text_field(attribute_name, :class => 'date_time_picker', input_html_options)
使用:
@builder.text_field(attribute_name, input_html_options.merge(:class => 'date_time_picker'))
它会起作用。
修改强>
再次阅读此答案后,我意识到此代码始终会覆盖:class
参数。如果您想使用被调参数而不是默认参数,则可以使用merge
实现此更改reverse_merge
。
<强> EDIT2 强>
只有当它是最后一个参数时,才能删除哈希选项参数的花括号。在这种情况下,text_fields
接受2个参数,:class
属于第二个参数。