Getting it ready
Hi there, welcome to the first part of the series of building API in rails. Let’s just start with what this series will cover
- Setting up our Ruby on Rails API only application with all necessary gems and stuff.
- Adding Rspec for the TDD approach.
- Building a CRUD RESTful APIs
- Serializing the API resources
- Securing our API with JWT
- Integration SWAGGER for api documentation
- and many more….
Setting up our Ruby on Rails API only application with all necessary gems and stuff
It’s quite easy to set up a ROR application and since ROR is a battery included framework we don’t have to worry about any configuration stuff.
Make sure that you have
- Ruby installed
- For this, we can install first RVM (Ruby Version Manager) then install the required ruby version. We will be using the latest ruby version which is 3.0.2 as of now.
-
Node js, npm, and Yarn installed
Although we will not need this since it’s API only application but it might come in handy later so it’s better to install it. Refer to this for installing Yarn.
For node, we can install it with nvm . I love using n as node version manager.
In Rails 7 Import Map is going to be the new and default way of importing javascript assets into the rails application so we might not even need node :man_shrugging
- Rails installed.
Open the terminal and enter
gem install rails
- Check your rails version with the
rails version
command. For this series, we will be using the Rails version 6.1.4
Now since we have everything needed let us go ahead and set up our application.
Go to terminal and enter
rails new api_app --api -d postgresql --skip-system-test --skip-test
So, you might have noticed the database we will be using which is Postgresql, and also I have skipped the test since we will be using Rspec for testing.
Please feel free to give your feedback on the comment section below or ping me at or . Have a great time