Cole Perry
Cole Perry

Reputation: 338

"YAML syntax error occurred while parsing config/database.yml" Ruby on Rails

Everytime I run my rails application I get this error pointing to "encoding: utf8" in the production section of database.yml. If I reload the page it takes me to the app but I'm afraid something is wrong with the database.

Here is my database.yml folder:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: b6f4e1d86a2a08
  password: 25205573
  host: us-cdbr-iron-east-05.cleardb.net

development:
  <<: *default
  database: DBProj_development

test:
  <<: *default
  database: DBProj_test


production:
  <<: *default
  adapter: mysql2
    encoding: utf8
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
    username: b6f4e1d86a2a08
    password: 25205573
    host: us-cdbr-iron-east-05.cleardb.net
    database: @localhost

I completely understand that YAML must be consistently indented using spaces. Tabs are not allowed.I do not think this is the problem. I have not found one only source to remedy this problem.

Upvotes: 1

Views: 2317

Answers (1)

elyalvarado
elyalvarado

Reputation: 1296

You have 2 issues there. Wrong level of indentation below adapter in the production label. And the value of the database label can't start with an @, so you have to place it between quotation marks:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: b6f4e1d86a2a08
  password: 25205573
  host: us-cdbr-iron-east-05.cleardb.net

development:
  <<: *default
  database: DBProj_development

test:
  <<: *default
  database: DBProj_test


production:
  <<: *default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: b6f4e1d86a2a08
  password: 25205573
  host: us-cdbr-iron-east-05.cleardb.net
  database: "@localhost"

That will fix your parsing issues.

Upvotes: 1

Related Questions