2012-12-23 130 views
2

我試着讓我的MySQL的測試數據庫設置並具有奇怪的錯誤,這些都是我的配置加載databsae.yml給出了一個錯誤

寶石文件

source 'https://rubygems.org' 

gem 'rails', '3.2.9' 

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

gem 'sqlite3' 
gem "mysql2" 

# 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' 

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

    gem 'uglifier', '>= 1.0.3' 
end 

group :test, :development do 
    gem "rspec-rails", "~> 2.0" 
    gem 'database_cleaner' 
    gem 'capybara' 
    gem "factory_girl_rails", ">= 4.1.0" 
    gem 'cucumber-rails', :require => false 
    gem 'mocha' 
    gem "shoulda-matchers" 
    gem "spork" 
    gem 'guard-rspec' 
    gem "guard-spork" 
    gem 'rb-inotify', '~> 0.8.8' 
    gem 'cucumber-rails', :require => false 
    gem 'cucumber-rails-training-wheels' #Still running on 'L' board 
end 

gem 'jquery-rails' 
gem "twitter-bootstrap-rails" 
gem "therubyracer", '0.10.2' 
gem "less-rails" 

gem 'devise' 
gem 'omniauth-google-oauth2' 
gem 'cancan' 

# To use debugger 
gem 'debugger' 
gem 'ruby-prof' 

我database.yml文件

# SQLite version 3.x 
# gem install sqlite3 
# 
# Ensure the SQLite 3 gem is defined in your Gemfile 
# gem 'sqlite3' 
development: 
    adapter: sqlite3 
    database: db/development.sqlite3 
    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: mysql2 
    username: root 
    password: root 
    host: localhost 
    database: bamboo_test 

production: 
    adapter: sqlite3 
    database: db/production.sqlite3 
    pool: 5 
    timeout: 5000 

cucumber: 
    <<: *test 

,這是我得到

[[email protected] bamboo]$ rake db:create:all 
rake aborted! 
can't convert nil into Hash 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.9/lib/rails/application/configuration.rb:115:in `database_configuration' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:25:in `block (2 levels) in <top (required)>' 
Tasks: TOP => db:create:all => db:load_config 
(See full trace by running task with --trace) 
[[email protected] bamboo]$ rake db:create:all --trace 
** Invoke db:create:all (first_time) 
** Invoke db:load_config (first_time) 
** Execute db:load_config 
rake aborted! 
can't convert nil into Hash 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `merge!' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `block in visit_Psych_Nodes_Mapping' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each_slice' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `visit_Psych_Nodes_Mapping' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:205:in `block in visit_Psych_Nodes_Mapping' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each_slice' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `visit_Psych_Nodes_Mapping' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/nodes/node.rb:25:in `to_ruby' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:107:in `load' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.9/lib/rails/application/configuration.rb:115:in `database_configuration' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:25:in `block (2 levels) in <top (required)>' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:185:in `each' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain' 
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load' 
/home/sameera/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>' 
Tasks: TOP => db:create:all => db:load_config 
錯誤

加載.yml文件時出現錯誤,但該文件對我來說似乎正常。任何幫助,將不勝感激。

回答

5

問題是,您在黃瓜部分中引用測試環境別名而未真正創建它。嘗試修改測試環境到這個:

test: &test 
    adapter: mysql2 
    username: root 
    password: root 
    host: localhost 
    database: bamboo_test 
+0

是的,這是問題,非常感謝幫助:D – sameera207