ActiveRecord :: ConnectionNotEstablished具有正确的YAML设置

时间:2012-06-06 16:09:12

标签: ruby-on-rails ruby ruby-on-rails-3 castle-activerecord

我刚开始使用新的spree应用程序。 我生成了项目,安装了capistrano和其他宝石。

当我运行rake db:create(和任何其他任务)时,我得到(使用--trace

rake aborted!
ActiveRecord::ConnectionNotEstablished
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:228:in `columns'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:248:in `column_names'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:61:in `ordering_condition_details'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:52:in `method_missing'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:105:in `<class:Base>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:104:in `<top (required)>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/spree_core-0.40.0/lib/spree_core.rb:47:in `<top (required)>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/spree-0.40.0/lib/spree.rb:1:in `require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/spree-0.40.0/lib/spree.rb:1:in `<top (required)>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
/home/dever/code/corsisulweb_it/config/application.rb:13:in `<top (required)>'
/home/dever/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/dever/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/dever/code/corsisulweb_it/Rakefile:5:in `<top (required)>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/dever/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/dever/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/home/dever/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'

当然我正确配置了config/database.yml(我在devbox上共享同一个db用户)。

这是Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.3'
gem 'mysql2', :groups => [:development, :test]

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

  gem 'therubyracer', :platform => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :development do
  gem 'capistrano'
end

group :production do
  gem 'pg'
end

gem 'spree'

这是config/database.yml

# MySQL.  Versions 4.1 and 5.0 are recommended.
# 
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: project_it_development
  pool: 5
  username: dever
  password: dever
  socket: /var/run/mysqld/mysqld.sock

# 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: mysql2
  encoding: utf8
  reconnect: false
  database: project_it_test
  pool: 5
  username: dever
  password: dever
  socket: /var/run/mysqld/mysqld.sock

production:
  adapter: postgres
  encoding: utf8
  reconnect: false
  database: project_it
  pool: 5
  username: user-production
  password: pwd-user-production
  socket: /var/run/mysqld/mysqld.sock

我运行bundle --without production因为我在本地机器上使用mysql而无法正确编译gem pg

我可以使用mysql客户端的凭据登录。这可能有什么问题?

1 个答案:

答案 0 :(得分:0)

您似乎使用的是旧版spree_core-0.40.0/lib/spree_core/find_by_param.rb:104:in

尝试在gemfile中指定它,如

gem 'spree', '1.1.0'

然后安装新版本和\或清除旧版本。