0

I'd like to use something like the following in my database.yml:

host: %x(boot2docker ip)

However, whenever I do this, I get back something like the following error:

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):

It seems clear to me that it's something about the way that boot2docker is responding with the ip is wrong, adding a newline or similar. I could put this somewhere else, but it seems right just to do it inline - is there an elegant (one line) way to do this?

aronchick
  • 6,786
  • 9
  • 48
  • 75

2 Answers2

0

maybe your yaml parser needs a double quote:

host: "%x(boot2docker ip)"
Greg
  • 6,571
  • 2
  • 27
  • 39
0

Turns out that database.yml is not a ruby file, it is just raw yml, in which templating works. If I want to execute ruby, I need to escape it.

The answer here was the following:

host: <%= %x(boot2docker ip) %>
aronchick
  • 6,786
  • 9
  • 48
  • 75