Rails 6 API Tutorial - API Pagination p.15

Опубликовано: 28 Октябрь 2024
на канале: Rails Pro
5,993
139

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...  

📖 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 - What is pagination and why do we need it
00:50 - Writing a test to describe how we want pagination to work
02:35 - Adding limit and offset to our ActiveRecord Books query
03:58 - Adding a test for offset
05:41 - Adding a maximum limit of 100 to prevent users requesting too many records
06:18 - Writing a test to verify that users cannot request too many records
07:54 - Adding an RSpec 'expect to receive' model expectation
09:46 - Implementing max limit logic using Ruby's min method
13:10 - Tidy up the limit method using a named constant
14:16 - Move the max limit test into a controller spec

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