zwiebl zwiebl - 6 months ago 16
Ruby Question

Translating a connection string to database.yml file in Ruby on Rails

The problem is fairly simple and straightforward. I have a database

connection string
and I want to make a corresponding
file from it.

The connection string is as follows:

data\SQL2012,3000;initial catalog=City;persist security info=True;user id=user_me;password=user_me##2009;

Now, the file I created is likewise:

adapter: sqlserver
port: 1433
database: City
username: user_me
password: user_me##2009

Now, the problem occurs in line 3: this\SQL2012
is syntax-highlighted, where as the
part stays white, not highlighted but just as a normal text

Also the problem in last line:
, it just recognizes
and then treats
as the comment, but this part is also a part of the password.

I noticed, if I used quotation marks, the highlighting is OK, but not sure should I use them?

My question is - how should the
file look like for the given connection string?


use quotes " to wrap the strings.

    adapter:    "sqlserver"
    host:       "\SQL2012,3000"
    port:       "1433"
    database:   "City"
    username:   "user_me"
    password:   "user_me##2009"

This way YML will only interpret these as strings and not as comments and other stuff.