Since learning Ruby, Ruby on Rails and PostgreSQL I recently learned that Rails will default to other SQL variants installed on my machine first like SQLite which I used in a recent project before moving on to PostgreSQL.
I'm sure I'm not the only one out there who didn't make sure that their Rails database wasn't configured to use Postgres automatically so I did some digging around to make this post to show you how to just that in 2 easy steps.
Make your project folder and
cd into it.
mkdir example-app cd example-app
Create the Rails backend with a PostgreSQL database using this command:
rails new my-example-app --api --database=postgresql
cding and running
bundle install in your new rails folder you're free to set up things like git if you want your work all in one repo. You can set up your React frontend in a subfolder with:
npm install --prefix client
Now you will never have the issue of wondering if you're using anything other than PostgreSQL for your Rails app! However the real work of actually building the Rails app has just begun but you can pat yourself on the back for getting this task done.