Member-only story

Setting Up Rails With PostgreSQL

Steven Klavins
2 min readMay 10, 2020

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response