On page 93, under the header “Setting up pagination with Kaminari”, the example which outlines how to add the Kaminari UrlHelper to the FilmsController appears to contain two versions of the same example.
The section starts with a code sample of FilmsController followed immediately by a similar but different sample of FilmsController.
To get the total amount of pages, Kaminari added the total_pages method to ActiveRecord. Try to modify the controller response yourself. You should get something similar to this:
rails-performance-book-completed/app/controllers/api/v1/films_controller.rb
require ‘kaminari/helpers/helper_methods’
class Api::V1::FilmsController < ApplicationController
[…]
# app/controllers/api/v1/films_controller.rb
require ‘kaminari/helpers/helper_methods’
class Api::V1::FilmsController < ApplicationController
include Kaminari::Helpers::UrlHelper
The samples differ only a little bit and there’s no discussion of the differences which makes me think this was some sort of editing error that slipped by.
Affected version: P1.0
Present in:
Print copy from Bookshop.org
epub file
pdf file