2014-03-26 2 views
7

Capistrano cap 배포를 사용하여 내 프로젝트를 배포하려고합니다. migrate, 내 별개의 database.yml에 오류가 발생합니다 (로컬 서버에서 제대로 실행 중입니다)rails4 - Psych :: BadAlias ​​: 알 수없는 별칭 : 테스트

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 

답변

9

내가 할 수 있습니다 별칭 테스트, 개발 또는 생산 그들은 환경이 생산하는 경우 당신이 (의 부팅 환경에 따라 할당 한, 믿을 수 없어 프로덕션 설정이 적용됩니다). 이 문제가 해결된다면 오이는 테스트 환경에서만 사용할 수 있습니다.

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 
+0

덕분에 .. – erwin

+1

그것을 가지고이 답변이 정확하지 :

나는 아래에 가까운 무언가를 사용했다. yaml 파일의 별칭에는 레일이하는 일과 관련된 ** 아무 것도 ** 없습니다. 파일을로드 할 때만 단축키입니다. 참조를 사용했는지 여부에 관계없이 파일을로드 한 후에 가져온 데이터는 동일하게 보입니다. – averell

+3

또한, 원래의 database.yml은 문제없이 작동해야합니다. 그 오류를 본 유일한 이유는 누군가가'# save_load'를 사용했기 때문입니다. 이것은 기본적으로 참조를 완전히 허용하지 않기 때문입니다. – averell

관련 문제