0

当完全按照指示完成第 5 章时,没有 RSpec 失败,我完成了 git add .、git commit 和 git push 的最后步骤。然后git push heroku。它看起来很成功,当我去 Heroku 站点进行测试时(http://stark-falls-6972.herokuapp.com/)它没有说“我们很抱歉,但是出了点问题”。

Heroku 日志命令并没有表明出现任何问题,尽管有一条关于贬低插件的消息,直到今天我才看到。我该如何解决?

heroku 日志:

2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:61:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2054987173047889544__call__2098061657375244569__callbacks'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-10-10T16:34:31+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-10-10T16:34:31+00:00 app[web.1]: 
2012-10-10T16:34:31+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-10-10T16:34:31+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-10-10T16:34:31+00:00 app[web.1]: 
2012-10-10T16:36:14+00:00 heroku[slugc]: Slug compilation started
2012-10-10T16:36:41+00:00 heroku[api]: Release v9 created by myemail@example.com
2012-10-10T16:36:41+00:00 heroku[api]: Deploy 90c0db8 by myemail@example.com
2012-10-10T16:36:41+00:00 heroku[web.1]: State changed from up to starting
2012-10-10T16:36:42+00:00 heroku[slugc]: Slug compilation finished
2012-10-10T16:36:44+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 58733`
2012-10-10T16:36:45+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2012-10-10T16:36:46+00:00 app[web.1]: [2012-10-10 16:36:46] ERROR SignalException: SIGTERM
2012-10-10T16:36:46+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
2012-10-10T16:36:47+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-10-10T16:36:47+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-10-10T16:36:49+00:00 app[web.1]: [2012-10-10 16:36:49] INFO  WEBrick 1.3.1
2012-10-10T16:36:49+00:00 app[web.1]: [2012-10-10 16:36:49] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-10-10T16:36:49+00:00 app[web.1]: [2012-10-10 16:36:49] INFO  WEBrick::HTTPServer#start: pid=2 port=58733
2012-10-10T16:36:50+00:00 heroku[web.1]: State changed from starting to up
2012-10-10T16:36:51+00:00 app[web.1]: 
2012-10-10T16:36:51+00:00 app[web.1]: => Booting WEBrick
2012-10-10T16:36:51+00:00 app[web.1]: => Call with -d to detach
2012-10-10T16:36:51+00:00 app[web.1]: => Rails 3.2.8 application starting in production on http://0.0.0.0:58733
2012-10-10T16:36:51+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-10-10T16:36:51+00:00 app[web.1]: 
2012-10-10T16:36:51+00:00 app[web.1]: Started GET "/" for 198.245.202.252 at 2012-10-10 16:36:51 +0000
2012-10-10T16:36:51+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2012-10-10T16:36:51+00:00 app[web.1]: 
2012-10-10T16:36:51+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in `retrieve_connection'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:61:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2960544894057171244__call__2838682389361938761__callbacks'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:144:in `connection'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:67:in `rescue in call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/l
ib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-10-10T16:36:51+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-10-10T16:36:51+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-10-10T16:36:51+00:00 app[web.1]: 
2012-10-10T16:36:51+00:00 app[web.1]: 
2012-10-10T16:36:51+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
2012-10-10T16:36:51+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-10-10T16:36:51+00:00 heroku[router]: GET stark-falls-6972.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=623ms status=500 bytes=643
2012-10-10T16:36:51+00:00 heroku[router]: GET stark-falls-6972.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=12ms status=200 bytes=0
2012-10-10T16:36:55+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2012-10-10T16:36:55+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2012-10-10T16:36:57+00:00 heroku[web.1]: Process exited with status 137

当我运行 heroku run rake db:migrate 时,我收到此消息。(ps 我最近开始看到这些折旧消息,据我所知,我没有添加任何插件)

Running `rake db:migrate` attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
Connecting to database specified by DATABASE_URL
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

Tasks: TOP => db:migrate => db:load_config

我的 database.yml 文件(在之前的高级练习中更新为 postgresql,我认为它有效):

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: postgresql
  database: db/development_postgresql
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: postgresql
  database: db/test_postgresql
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: db/production_postgresql
  pool: 5
  timeout: 5000

我的宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.4'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
    gem 'pg', '0.12.2'
    gem 'rspec-rails', '2.11.0'
    gem 'guard-rspec', '1.2.1'
  gem 'guard-spork', '1.2.0'
  gem 'spork', '0.9.2'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.5'
  gem 'coffee-rails', '~> 3.2.2'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.2.3'
end

gem 'jquery-rails', '2.0.2'

group :test do
    gem 'capybara', '1.1.2'
    gem 'rb-inotify', '0.8.8'
    gem 'libnotify', '0.5.9'
end


# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'
4

1 回答 1

2

确保您的应用在本地运行。即当您从 localhost:3000 访问它时

上面的heroku堆栈跟踪中的相关错误消息是ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)

所以 Heroku 无法连接到数据库。检查以确保您已遵循所有以前的 heroku 设置相关配置。

Heroku 支持 postgresdb;因此pggem 必须包含在 Gemfile 中,如此清单中所述

还要检查这些 heroku 部署步骤,尤其是$ heroku run rake db:migrate步骤。(重复此步骤无害)。

这是一个 Stack Overflow 线程,它详细处理相同的错误消息:Ruby - ActiveRecord::ConnectionNotEstablished 希望该页面能够引导您找到正确的答案。

祝你学习 Rails 好运。RailsTutorial 是适合初学者的最佳资源!

于 2012-10-10T21:10:18.127 回答