ruby-on-rails – rails4 – Psych :: BadAlias:未知别名:test

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – rails4 – Psych :: BadAlias:未知别名:test前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试使用Capistrano cap deploy部署我的项目:迁移,我在我的 database.yml上的测试别名中出错(这在本地服务器上运行正常)
development:
   database: db_dev
   adapter: MysqL2
   username: xxxxxx
   password: xxxxxx
   host: localhost
   encoding: utf8

test: &test
   database: db_test
   adapter: MysqL2
   username: xxxxxx
   password: xxxxxx
   host: localhost
   encoding: utf8

production:
   database: db_prod
   adapter: MysqL2
   username: xxxxxxxx
   password: xxxxxxx
   host: localhost
   encoding: utf8

cucumber:
   <<: *test

控制台日志是:

rake aborted!
   Psych::BadAlias: Unknown alias: test
   /railties-4.0.3/lib/rails/application/configuration.rb:106:in `database_configuration'
   /activerecord-4.0.3/lib/active_record/railtie.rb:175:in `block (2 levels) in <class:Railtie>'
   /activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
   /activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
   /activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
   /activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `each'
   /activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
   /activerecord-4.0.3/lib/active_record/railtie.rb:174:in `block in <class:Railtie>'
   /railties-4.0.3/lib/rails/initializable.rb:30:in `instance_exec'
   /railties-4.0.3/lib/rails/initializable.rb:30:in `run'
   /railties-4.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'
   /railties-4.0.3/lib/rails/initializable.rb:54:in `run_initializers'
   /railties-4.0.3/lib/rails/application.rb:215:in `initialize!'
   /railties-4.0.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
   /home/kadoudal/rails/swim-tech.eu/site/swimtech/releases/20140326140458/config/environment.rb:6:in `<top (required)>'
   /activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
   /activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
   /activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
   /activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
   /railties-4.0.3/lib/rails/application.rb:189:in `require_environment!'
   /railties-4.0.3/lib/rails/application.rb:250:in `block in run_tasks_blocks'
   Tasks: TOP => db:migrate => environment

解决方法

我不相信您可以根据您引导的环境分配测试,开发或生产别名(如果环境是生产环境,则将应用生产设置).问题是,如果这样做,黄瓜只能在测试环境中使用.

我使用了类似于下面的东西:

base: &base
     adapter: MysqL2
     host: address.com
     encoding: utf8
     adapter: MysqL2
     username: xxxxxx
     password: xxxxxx

  development:
     database: db_dev
     <<: *base

  test:
     database: db_test
     <<: *base

  production:
     database: db_prod
     <<: *base

  cucumber:
     database: cucumber
     <<: *base
原文链接:https://www.f2er.com/ruby/269673.html

猜你在找的Ruby相关文章