Assuming a Book class exist and it has many chapters, and also assuming that the chapter has a position number stored in the database, I'd do something like:
class Chapter < ApplicationRecord
book.chapters.find_by(position: position + 1)
book.chapters.find_by(position: position - 1)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.