Ruby Rails 教程 Heroku 部署问题

Ruby on Rails Tutorial Heroku Deployment Issue

我已经在 Rails 教程中开始了 Ruby 教程:

https://www.railstutorial.org/book/beginning#sec-deploying

我正在在线使用 cloud9 IDE 并尝试在 Heroku 上部署我的 hello world 应用程序,但是当我尝试打开该应用程序时,我收到以下错误:

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.

根据日志,似乎是 postgres pg gem 的问题。这是 gem 文件:

source 'https://rubygems.org'

gem 'rails',        '4.2.2' 
gem 'sass-rails',   '5.0.2' 
gem 'uglifier',     '2.5.3' 
gem 'coffee-rails', '4.1.0' 
gem 'jquery-rails', '4.0.3' 
gem 'turbolinks',   '2.3.0' 
gem 'jbuilder',    '2.2.3' 
gem 'sdoc',         '0.4.0', group: :doc

group :development, :test do   
gem 'sqlite3',     '1.3.9'   
gem 'byebug',      '3.4.0'   
gem 'web-console', '2.0.0.beta3'   
gem 'spring',      '1.1.3' end

group :production do   
gem 'pg',             '0.17.1'   
gem 'rails_12factor', '0.0.2' 
end

为了准备系统部署到生产环境,我们 运行 捆绑安装带有一个特殊标志以防止本地安装任何生产 gems(在本例中由 pg 和 rails_12factor):

$ bundle install --without production

根据教程,这是用 pg 和 rails_12factor gems 更新 Gemfile.lock。然而这是 Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.2)
      actionpack (= 4.2.2)
      actionview (= 4.2.2)
      activejob (= 4.2.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.2)
      actionview (= 4.2.2)
      activesupport (= 4.2.2)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.2)
      activesupport (= 4.2.2)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.2)
      activesupport (= 4.2.2)
      globalid (>= 0.3.0)
    activemodel (4.2.2)
      activesupport (= 4.2.2)
      builder (~> 3.1)
    activerecord (4.2.2)
      activemodel (= 4.2.2)
      activesupport (= 4.2.2)
      arel (~> 6.0)
    activesupport (4.2.2)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arel (6.0.3)
    binding_of_caller (0.7.3.pre1)
      debug_inspector (>= 0.0.1)
    builder (3.2.2)
    byebug (3.4.0)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.9.1.1)
    columnize (0.9.0)
    debug_inspector (0.0.2)
    debugger-linecache (1.2.0)
    erubis (2.7.0)
    execjs (2.6.0)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    i18n (0.7.0)
    jbuilder (2.2.3)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.6.2)
    mini_portile (0.6.2)
    minitest (5.8.0)
    multi_json (1.11.2)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.2)
      actionmailer (= 4.2.2)
      actionpack (= 4.2.2)
      actionview (= 4.2.2)
      activejob (= 4.2.2)
      activemodel (= 4.2.2)
      activerecord (= 4.2.2)
      activesupport (= 4.2.2)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.2)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.2)
      loofah (~> 2.0)
    railties (4.2.2)
      actionpack (= 4.2.2)
      activesupport (= 4.2.2)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rdoc (4.2.0)
    sass (3.4.18)
    sass-rails (5.0.2)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.0)
      json (~> 1.8)
      rdoc (~> 4.0, < 5.0)
    slop (3.6.0)
    spring (1.1.3)
    sprockets (3.3.4)
      rack (~> 1.0)
    sprockets-rails (2.3.3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    sqlite3 (1.3.9)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (1.4.1)
    turbolinks (2.3.0)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.5.3)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.0.0.beta3)
      activemodel (~> 4.0)
      binding_of_caller (= 0.7.3.pre1)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
  ruby

DEPENDENCIES
  byebug (= 3.4.0)
  coffee-rails (= 4.1.0)
  jbuilder (= 2.2.3)
  jquery-rails (= 4.0.3)
  rails (= 4.2.2)
  sass-rails (= 5.0.2)
  sdoc (= 0.4.0)
  spring (= 1.1.3)
  sqlite3 (= 1.3.9)
  turbolinks (= 2.3.0)
  uglifier (= 2.5.3)
  web-console (= 2.0.0.beta3)

bundle 是否应该将 pg 添加到 Gemfile.lock?

应用 运行 在云端 rails 服务器上运行良好 IDE。这是完整的日志,以防它有帮助:

2015-09-22T16:24:37.291738+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
2015-09-22T16:24:37.291740+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2015-09-22T16:24:37.291743+00:00 app[web.1]:    from /app/config.ru:3:in `require'
2015-09-22T16:24:37.291753+00:00 app[web.1]:    from /app/config.ru:in `new'
2015-09-22T16:24:37.291748+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
2015-09-22T16:24:37.291744+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2015-09-22T16:24:37.291752+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-09-22T16:24:37.291760+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-09-22T16:24:37.291757+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2015-09-22T16:24:37.291762+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-09-22T16:24:37.291768+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
2015-09-22T16:24:37.291765+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
2015-09-22T16:24:37.291772+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-09-22T16:24:37.291773+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:61:in `app'
2015-09-22T16:24:37.291780+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-09-22T16:24:37.291777+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-09-22T16:24:37.291783+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:80:in `start'
2015-09-22T16:24:37.291786+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-09-22T16:24:37.291790+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-09-22T16:24:37.291793+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-09-22T16:24:37.291796+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-09-22T16:24:37.291800+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
2015-09-22T16:24:37.291803+00:00 app[web.1]:    from bin/rails:8:in `require'
2015-09-22T16:24:37.291805+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2015-09-22T16:24:37.322146+00:00 app[web.1]: => Booting WEBrick
2015-09-22T16:24:37.322150+00:00 app[web.1]: => Rails 4.2.2 application starting in production on http://0.0.0.0:13217
2015-09-22T16:24:37.322152+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-09-22T16:24:37.322155+00:00 app[web.1]: Exiting
2015-09-22T16:24:37.322154+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-09-22T16:24:38.408303+00:00 heroku[web.1]: Process exited with status 1
2015-09-22T16:24:38.423692+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-22T16:24:38.423692+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-22T16:24:41.679761+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 59157 -e production`
2015-09-22T16:24:44.946057+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
2015-09-22T16:24:44.946084+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
2015-09-22T16:24:44.946088+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
2015-09-22T16:24:44.946091+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
2015-09-22T16:24:44.946096+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
2015-09-22T16:24:44.946086+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_handling.rb:50:in `establish_connection'
2015-09-22T16:24:44.946089+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
2015-09-22T16:24:44.946097+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:44:in `each'
2015-09-22T16:24:44.946099+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
2015-09-22T16:24:44.946100+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/base.rb:316:in `<module:ActiveRecord>'
2015-09-22T16:24:44.946102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/base.rb:26:in `<top (required)>'
2015-09-22T16:24:44.946103+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:118:in `<class:PredicateBuilder>'
2015-09-22T16:24:44.946104+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:2:in `<module:ActiveRecord>'
2015-09-22T16:24:44.946106+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:1:in `<top (required)>'
2015-09-22T16:24:44.946107+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
2015-09-22T16:24:44.946109+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
2015-09-22T16:24:44.946110+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
2015-09-22T16:24:44.946111+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
2015-09-22T16:24:44.946113+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `block in eager_load!'
2015-09-22T16:24:44.946114+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `each_value'
2015-09-22T16:24:44.946115+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `eager_load!'
2015-09-22T16:24:44.946116+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record.rb:158:in `eager_load!'
2015-09-22T16:24:44.946118+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application/finisher.rb:56:in `each'
2015-09-22T16:24:44.946119+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
2015-09-22T16:24:44.946122+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec'
2015-09-22T16:24:44.946124+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `run'
2015-09-22T16:24:44.946125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
2015-09-22T16:24:44.946127+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-09-22T16:24:44.946126+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-09-22T16:24:44.946130+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-09-22T16:24:44.946129+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-09-22T16:24:44.946134+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
2015-09-22T16:24:44.946133+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-09-22T16:24:44.946135+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers'
2015-09-22T16:24:44.946131+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
2015-09-22T16:24:44.946142+00:00 app[web.1]:    from /app/config.ru:3:in `require'
2015-09-22T16:24:44.946139+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
2015-09-22T16:24:44.946140+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2015-09-22T16:24:44.946144+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
2015-09-22T16:24:44.946143+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2015-09-22T16:24:44.946149+00:00 app[web.1]:    from /app/config.ru:in `new'
2015-09-22T16:24:44.946146+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-09-22T16:24:44.946153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-09-22T16:24:44.946150+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2015-09-22T16:24:44.946164+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-09-22T16:24:44.965501+00:00 app[web.1]: => Rails 4.2.2 application starting in production on http://0.0.0.0:59157
2015-09-22T16:24:44.946167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-09-22T16:24:44.946158+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
2015-09-22T16:24:44.946162+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:61:in `app'
2015-09-22T16:24:44.946159+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-09-22T16:24:44.965496+00:00 app[web.1]: => Booting WEBrick
2015-09-22T16:24:44.946171+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-09-22T16:24:44.946175+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-09-22T16:24:44.946176+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-09-22T16:24:44.946179+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-09-22T16:24:44.946183+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
2015-09-22T16:24:44.946186+00:00 app[web.1]:    from bin/rails:8:in `require'
2015-09-22T16:24:44.946187+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2015-09-22T16:24:44.965503+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-09-22T16:24:44.965504+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-09-22T16:24:44.946156+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
2015-09-22T16:24:44.965506+00:00 app[web.1]: Exiting
2015-09-22T16:24:44.946152+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-09-22T16:24:44.946168+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:80:in `start'
2015-09-22T16:24:45.724447+00:00 heroku[web.1]: Process exited with status 1
2015-09-22T16:24:45.739191+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-22T16:24:47.758235+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=infinite-inlet-3994.herokuapp.com request_id=c19b75bd-8c4a-427f-975d-b81f87ddc7ed fwd="46.7.54.39" dyno= connect= service= status=503 bytes=
2015-09-22T16:25:00.442110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=infinite-inlet-3994.herokuapp.com request_id=f26af351-7605-4fd8-a7f6-2da6996d5f1d fwd="46.7.54.39" dyno= connect= service= status=503 bytes=
WARNING: Toolbelt v3.42.2 update available.

这是 Rails 输出的错误:

Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)

当然,Heroku默认以运行PostgreSQL出名

这个错误有两种可能性:

  1. Something is wrong with your Rails app (IE the PG gem is not loaded)
  2. Heroku doesn't have the db created or accessible

--

我唯一遇到过 Heroku 问题的时候是我没有创建或验证数据库。

我会这样做:

Gem

将您的 PG gem 放入 gem 文件的常规部分。我知道这可能会导致您的开发环境出现问题;它将允许 Heroku 加载 gem。您以后可以随时将其改回:

#Gemfile
source 'https://rubygems.org'

gem 'pg'
gem 'rails',        '4.2.2' 
gem 'sass-rails',   '5.0.2' 
gem 'uglifier',     '2.5.3' 
gem 'coffee-rails', '4.1.0' 
gem 'jquery-rails', '4.0.3' 
gem 'turbolinks',   '2.3.0' 
gem 'jbuilder',    '2.2.3' 
gem 'sdoc',         '0.4.0', group: :doc

数据库

在 Heroku 中,确保您已设置数据库并将其凭据添加到您的 #config/database.yml 文件中:

Tutorial

基本上,如果您设置了 Heroku PG 数据库,将凭据添加到 database.yml 文件,然后使用上述教程迁移到数据库,应该可以解决此问题。