So you have created your Rails app only to realise you’ve made some kind of error. You could just delete the folder, but that leaves the app’s databases behind in Postgres, quietly cluttering things up forever.

The clean way around this is to cd into the app directory and run:

rails db:drop
cd .. && rm -rf app_name

First we drop the app’s databases - both development and test go together. If something is still connected and the drop fails, see my other article about force dropping a database.

Then cd .. steps out of the directory, and rm -rf removes the folder and everything in it. Standard warning applies: rm -rf does not ask twice, so double-check what you’ve typed before hitting enter.

Once this has executed, your app and its databases are gone, and the name is free for attempt number two.