Job component in app platform to run rails migrations and this error occurs - URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

I have a rails app with a managed development database and I am trying to add a job to migrate my rails app before each deploy.

I set the environment variable DATABASE_URL with a value of ${db.DATABASE_URL}.

But it seems like the connection parameters are not being passed and instead is passing a string directly which causes this error.

URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

How can I pass the database connection parameters correctly in a job?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @DrewTerry

Try to define your DATABASE_URL as follows:


Then you must create the environment variable in .bashrc file:

$ nano ~/.bashrc

Puts your DATABASE_URL variable at the end of the file:

export DATABASE_URL="postgres://user:pass@localhost/dbname"

Finally, saves file and execute the content of the file:

$ source ~/.bashrc

Hope helps you,

Sergio Turpín