ruby - Error when loading YAML config files in Rails -


i configuring rails mongodb, , find strange problem when paring config/mongo.yml file.

config/mongo.yml generated executing script/rails generate mongo_mapper:config, , looks following:

defaults: &defaults   host: 127.0.0.1   port: 27017  development:   <<: *defaults   database: tc_web_development  test:   <<: *defaults   database: tc_web_test 

from config file can see objects development , test should both have database field. when parsed , loaded in config/initializers/mongo.db,

config = yaml::load(file.read(rails.root.join('config/mongo.yml'))) puts config.inspect mongomapper.setup(config, rails.env) 

the strange thing comes: output of puts config.inspect

{"defaults"=>{"host"=>"127.0.0.1", "port"=>27017}, "development"=>{"host"=>"127.0.0.1", "port"=>27017}, "test"=>{"host"=>"127.0.0.1", "port"=>27017}} 

which not contain database attribute. when execute same statements in plain ruby console, instead of using rails console, mongo.yml parsed in right way.

{"defaults"=>{"host"=>"127.0.0.1", "port"=>27017}, "development"=>{"host"=>"127.0.0.1", "port"=>27017, "database"=>"tc_web_development"}, "test"=>{"host"=>"127.0.0.1", "port"=>27017, "database"=>"tc_web_test"}} 

i wondering may cause of problem. ideas? thanks.

similar question has been answered here


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -