Member-only story
Setting Up Rails With PostgreSQL
In this post, I will explain how I set up a Ruby on Rails project with PostgreSQL. As default Rails comes configured with SQLite, this is incredibly convenient however it serves some limitation and most projects are not deployed with this database. I have the preference of setting my project up with my desired database from the very start of a project, thankfully Rails does allow us to do this.
Please ensure you have followed the official Rails guide to ensure everything you need is installed and ensure you have PostgreSQL installed.
Take a look at the following command
$ $ rails new my-new-rails-project --database=postgresql
Here we are setting up a Rails project in the same way we always would however as you can see we have also included --database=postgresql. Rails is very flexible and allow’s us to select our database of choice from the very start.

Within config/database.yml we can configure our database depending on our environment. We can generate a database for testing and development by running the following command.
$ rake db:create
Rake is a Ruby tool, often likened to Unix’s make tool, It is used to handle commands or tasks which are stored in what's called a Rakefile. We can in fact write our own tasks for Rake to run…