2015-04-19 31 views
0

我想使用類似我的database.yml以下幾點:在你的database.yml中使用'boot2docker ip'?

host: %x(boot2docker ip) 

但是,每當我這樣做,我回去類似以下錯誤:

RuntimeError (YAML syntax error occurred while parsing ...-database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): found character that cannot start any token while scanning for the next token at line 12 column 9):

在我看來很清楚,boot2docker對ip的響應方式是錯誤的,增加了一個換行符或類似的東西。我可以把它放在別的地方,但它看起來是正確的,只是做內聯 - 是否有一個優雅(一條線)的方式來做到這一點?

+0

或者說,YAML文件不只是Ruby文件。 –

+0

@DaveNewton對,但rails做了一些解釋 - 例如它支持模板結構 – aronchick

+0

聽起來像是yaml語法錯誤,用yaml驗證器或yamllint驗證yaml – resultsway

回答

0

原來,database.yml的是不是一個Ruby文件,它只是原始YML,其中模板工程。如果我想執行紅寶石,我需要逃避它。

答案這裏是以下幾點:

host: <%= %x(boot2docker ip) %> 
0

也許你的YAML解析器需要一個雙引號:

host: "%x(boot2docker ip)" 
相關問題