title: My Rails Tutorial (Chapter 7) Heroku deployment with puma keeps crashing
body: <p>This is my first question here so I hope I'm within the rules.</p>
  
  <p>I've just completed Chapter 7 of the Michale Hartl Rails Tutorial. My sample_app works locally and has worked on Heroku until this point.</p>
  
  <p>At the end of the chapter is a section called "7.5 Professional-grade deployment." This switches the production environment to SSL and the Puma web server.</p>
  
  <p>The following code shows the changes I've made as part of this section, which led to the app not working on Heroku.</p>
  
  <p><strong>config/environments/production.rb</strong> - uncommented this line to enable SSL</p>
  
  <pre><code>config.force_ssl = true
  </code></pre>
  
  <p><strong>Gemfile</strong> - added Puma</p>
  
  <pre><code>group :production do
    gem 'pg', '0.17.1'
    gem 'rails_12factor', '0.0.2'
    gem 'puma', '2.11.1'
  end
  </code></pre>
  
  <p><strong>config/puma.rb</strong> - I copied this direct from the Heroku site after copying from the Rails Tutorial pdf failed</p>
  
  <pre><code>workers Integer(ENV['WEB_CONCURRENCY'] || 2)
  threads_count = Integer(ENV['MAX_THREADS'] || 5)
  threads threads_count, threads_count
  
  preload_app!
  
  rackup      DefaultRackup
  port        ENV['PORT']     || 3000
  environment ENV['RACK_ENV'] || 'development'
  
  on_worker_boot do
    # Worker specific setup for Rails 4.1+
    # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
    ActiveRecord::Base.establish_connection
  end
  </code></pre>
  
  <p>Created the <strong>Procfile</strong></p>
  
  <pre><code>web: bundle exec puma -C config/puma.rb
  </code></pre>
  
  <p>After committing, pushing to Heroku and migrating the database, I get a page that says "Application error."</p>
  
  <p>This is the output of <strong>heroku logs</strong>:</p>
  
  <pre><code>2015-05-14T11:55:46.257652+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
  2015-05-14T11:55:48.438024+00:00 app[web.1]: ...                               ^
  2015-05-14T11:55:48.438026+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
  2015-05-14T11:55:48.438029+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
  2015-05-14T11:55:48.438035+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/bin/puma:10:in `&lt;top (required)&gt;'
  2015-05-14T11:55:48.438034+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
  2015-05-14T11:55:48.438017+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `instance_eval': config/puma.rb:1: syntax error, unexpected tIDENTIFIER, expecting end-of-input (SyntaxError)
  2015-05-14T11:55:48.438040+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/bin/puma:23:in `&lt;main&gt;'
  2015-05-14T11:55:48.438031+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
  2015-05-14T11:55:48.438039+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/bin/puma:23:in `load'
  2015-05-14T11:55:48.437914+00:00 app[web.1]: config/puma.rb:1: warning: encountered \r in middle of line, treated as a mere space
  threads_count = Integer(ENV['MAX_THREADS']......NCURRENCY'] || 2)
  2015-05-14T11:55:49.211862+00:00 heroku[web.1]: Process exited with status 1
  2015-05-14T11:55:49.223366+00:00 heroku[web.1]: State changed from starting to crashed
  </code></pre>
  
  <p>I get the impression from "syntax error" that there's something wrong with my config/puma.rb file, but I can't work out what.</p>
  
  <p>I tried specifying the Ruby version number, but that didn't help.</p>
  
  <p>What's wrong with this and how can I put it right?</p>