ActiveRecord :: AdapterNotSpecified - 未配置数据库

时间:2016-03-30 08:56:31

标签: ruby-on-rails activerecord rails-activerecord ibm-cloud

将Ruby on Rails应用程序推送到Bluemix时,我开始遇到此错误。我的应用程序实际上并不需要数据库,但我在

中有以下内容
database.yml:
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

在我的Gemfile中:

gem 'sqlite3' # Use sqlite3 as the database for Active Record

group :production do
    gem 'rails_serve_static_assets'
end

这些是我得到的错误:

       Could not detect rake tasks
       ensure you can run `$ bundle exec rake -P` against your app with no environment variables present
       and using the production group of your Gemfile.
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
       DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:"") instead. (called from <top (required)> at /tmp/staged/app/Rakefile:6)
       rake aborted!
       ActiveRecord::AdapterNotSpecified: '' database is not configured. Available: ["production"]
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:240:in `resolve_string_connection'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:267:in `resolve_hash_connection'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:228:in `resolve_connection'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:152:in `resolve'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:164:in `block in resolve_all'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:163:in `each'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:163:in `resolve_all'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:69:in `resolve'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/core.rb:46:in `configurations='
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/core.rb:48:in `block in <module:Core>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `class_eval'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `append_features'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:297:in `include'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:297:in `<class:Base>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:282:in `<module:ActiveRecord>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:23:in `<top (required)>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:39:in `require'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:39:in `block in <class:Railtie>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `instance_exec'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:245:in `each'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:245:in `each_registered_block'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `run_tasks_blocks'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/application.rb:361:in `block in run_tasks_blocks'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine/railties.rb:13:in `each'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine/railties.rb:13:in `each'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/application.rb:361:in `run_tasks_blocks'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine.rb:449:in `load_tasks'
       /tmp/staged/app/Rakefile:6:in `<top (required)>'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
       /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
       vendor/bundle/bin/rake:16:in `load'
       vendor/bundle/bin/rake:16:in `<main>'
###### WARNING:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.2.3'

1 个答案:

答案 0 :(得分:0)

看起来没有设置RAILS_ENV变量。我没有使用Bluemix所以不知道如何在那里导出变量。如果您不需要数据库,则不必包含activerecord。有关如何删除activerecord的详细信息,请参阅以下thread