加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 04:39:10 所属栏目:百科 来源:网络整理
导读:尝试使用Capistrano cap deploy部署我的项目:迁移,我在我的 database.yml上的测试别名中出错(这在本地服务器上运行正常) development: database: db_dev adapter: mysql2 username: xxxxxx password: xxxxxx host: localhost encoding: utf8test: test data
尝试使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读