Setup Ruby on Rails API

Luis Castillo
1 min readMar 21, 2022

Rails::API is a subset of a typical Rails application, created for applications that don’t require all functionality that a complete Rails application provides. It is a bit more lightweight and, consequently, faster than a typical Rails application. The primary example of its usage is in API applications only, where you usually don’t need the entire Rails middleware stack or template generation.

How to create a Rails API?

First of all, to create a Rails API, a few things need to be done in your operating system. Ruby needs to be installed on your computer as well rails; after these two are installed, you can run the following command code to generate a Rails API:

rails new [name] --api

When we run this command line, a few things are generated by default rails only set up SQLite, a lite database. If you need to have a different database like Postgres, a change can be done in the Gemfile by adding gem ‘pg.’ This. will install the Postgres database the next time you run bundle install.

--

--