Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded Ruby in database.yml not being parsed in RubyMine

I am using RubyMine 7.0.4 to build a Rails(4.2.0) application with Postgres as my database. I am using environment variables to hold my local configuration (DB_USERNAME and DB_PASSWORD), but RubyMine can't parse the embedded ruby in the database.yml file.

database.yml excerpt:

...
development:
  <<: *default
  database: my_app_development
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
...

RubyMine Error Popup

I even tried switching it to the actual credentials within the <%= %> tags, but same issue:

...
development:
  <<: *default
  database: my_app_development
  username: <%= 'my_app' %>
  password: <%= 'password' %>
...

This seems to be a RubyMine issue, since everything is executing perfectly from the command line/the application works fine. However, I like having my database integrated with the IDE, so it'd be great if I could get this working again.

Is there anything that I can do to execute the embedded ruby instead of treating it as a string?

like image 866
Lee Avatar asked Oct 28 '25 15:10

Lee


1 Answers

This is a bug within RubyMine that is unfortunately still not yet fixed.

For further info please refer to https://youtrack.jetbrains.com/issue/RUBY-9223

The only fix I managed to come up with so far, is to add the database.yml to your .gitignore file (if you're pushing your project to a remote repo) and store the username and password as plain text.

The second approach could be just inputting your db_password and db_username as plain texts for development and test databases, and using ENV["DB_USERNAME"] and ENV["DB_PASSWORD"] for the production DB only.

like image 56
Alexander Avatar answered Oct 31 '25 06:10

Alexander