codeinspired
codeinspired

Reputation: 366

Deployment of Rails 4 App to Heroku generates error

My Rails 4 application works perfectly on my local machine, but when I deploy to Heroku I get an application error. The error occurs even though Heroku says the deployment was successful. The text of the error message is:

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.

To troubleshoot the problem, I ran "heroku logs" in the console, which generated the following:

2015-06-18T00:42:56.355811+00:00 heroku[api]: Release v84 created by [email protected]
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=

I'm not certain, but I think I've identified the source of the problem. The following line stands out to me:

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)

Here's the contents of my simple_form helper file:

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

Note that before I coded the helper file, I could successfully deploy the application to Heroku. It appears Heroku is balking at my syntax - particularly, the closing parenthesis). However, I don't know how to correct the issue. What do I need to do to satisfy Heroku? I'd appreciate any help in getting my application successfully deployed again. Thanks!

Upvotes: 1

Views: 44

Answers (1)

Alejandro Babio
Alejandro Babio

Reputation: 5239

Just replace:

@builder.text_field(attribute_name, :class => 'date_time_picker', input_html_options)

With:

@builder.text_field(attribute_name, input_html_options.merge(:class => 'date_time_picker'))

And it will do the trick.

Edit After reading again this answer I realize that this code always overwrite the :class parameter. If you want use the called parameter instead of the default parameter, you can achieve this changing merge with reverse_merge.

Edit2 You can remove the curly braces of a hash option parameter only if it is the last parameter. For this case, text_fields accepts 2 parameters and :class belongs to the second.

Upvotes: 1

Related Questions