Deploying a Ruby on Rails API

Yosef S Adelman
2 min readSep 23, 2021

These are some notes from my experience deploying a Ruby on Rails backend to Heroku, with a persisted PostgreSQL database. Until I had a great chat with an alumnus from Flatiron (Thanks Arthur!), I had thought that Heroku was not capable of persisting anything. Breaking news folks. It can, and you can. A persisted database is an addon in the Heroku system, and all it takes is to enable it. It was definitely a pain to work through, so here are some of my notes.

I recently had to perform a complete reset of my Windows 10 system (even the best have bugs that can’t go away magically), and I had to redo much of my development environment, including installing Heroku.

I got an error while trying to install Heroku on WSL 2 as follows:

error: cannot communicate with server: Post http://localhost/v2/snaps/heroku: dial unix /run/snapd.socket: connect: no such file or directory

This is the link to the answer that fixed the above problem for me. https://stackoverflow.com/a/64999358/12826372

I also had incompatibility issues between my version of ruby and my version of Heroku stack. Apparently there are different versions of Heroku itself, and within that there are different stacks (??). If you are more familiar with this or have a good resource for understanding this sea of information, please let me know. Regardless, changing the stack of Heroku is done with a simple command:

heroku stack:set heroku-18

I also went through quite a headache while tinkering with my version of ruby. Somehow I was able to install a new version, but was unable to use it. Much pain all around. Don’t feel too bad, things are working now.

Finally, Heroku had a great plan breakdown that clearly defines at what point you would be considering a plan that needed to be paid for. I was pleasantly surprised to see how much I could test and experiment with without having to dip into my wallet. Here is a link to the page where all this is laid out:

https://elements.heroku.com/addons/heroku-postgresql

Again, if you have anything that can be contributed, please let me know. Or not, I guess that’s also okay.

--

--

Yosef S Adelman

Hey, I’m a software engineering graduate from Flatiron School.