Rails 6 API Tutorial - Finding the user and adding their ID to the JWT payload p.21

Опубликовано: 18 Июнь 2026
на канале: Rails Pro
3,828
96

In this video series we will build a Rails API from scratch. Backend APIs are useful for serving data to frontend applications, mobile apps or other backend services.

✨ Check out the new version of this video series, which has been updated for Rails 7    • Rails 7 API Tutorial - Create project and ...  

📖 You can also purchase the eBook and code for the new Rails 7 tutorial - https://tomkadwill.gumroad.com/l/rail...

This video covers:
00:00 - Introduction
00:13 - Generating a User model
00:59 - Finding the user, from params, in the authentication controller
01:37 - Calling AuthenticationTokenService and passing in the User ID
02:22 - Running the migrations
02:56 - Using FactoryBot to create a user in the specs
05:01 - Updating AuthenticationTokenService to receive user_id and add it to the JWT payload
06:25 - Fixing the AuthenticationTokenService spec
07:41 - Deleting unused pending spec
08:05 - Creating a User in the DB, in order to manually test authentication
08:48 - Testing the authenticate API via cURL
10:47 - Updating the controller to return the JWT generated from AuthenticationTokenService
12:01 - Checking the JWT on jwt.io

If you’re new to this series, you may want to start with part 1:    • Rails 6 API Tutorial - Create project and ...