Rails 5 API with PostgreSQL

A short guide to create Rails 5 API only application with PostgreSQL as database.

This guide assume users's are installed with latest version of Rails (5) and using GNU/Linux distribution

Step 1 : Create a Rails 5 API only application

# rails new my_rails_app => traditional app, includes front end boilerplates
# rails new my_rails_api_app => excludes unncessory front end boilerplates
$ rails new my_rails_api_app --api --database=postgresql 

Step 2 : Move inside your newly created Rails applicaction directory

$ cd my_rails_api_app

Step 3 : Add database name and password in database.yml

  username: <user_name>
  database: <database_name>
  password: <database_password>

Thats it. You are good to go.

Last updated