Pagination
How this page is built
the gem renders it — this is all you write
Pagination works in a custom layout too. You still paginate in the controller (kaminari); the cards layout feeds collection.page_scope to kaminari's own paginate helper, so the pager below is kaminari's default markup — styling it is your job, as always with kaminari.
app/controllers/books_controller.rb
@query = CrudComponents::Query.new(Book, params, fieldset: :index, ability: current_ability)
@books = @query.apply(Book.all).page(params[:page]).per(8) # kaminari
app/views/crud_components/layouts/_cards.html.erb
<%= paginate collection.page_scope %> <%# kaminari's own pager, inside your card layout %>
app/views/pagination/index.html.erb
<%= crud_collection @books, query: @query, layout: :cards %>
Read more: Pagination · Add a layout
The Distant Garden 34
- Author names
- Ted Chiang
- Genre
- Nonfiction
- Price
- 25.55 €
- Publisher
- Ace
- Active
- ✓
The Endless Door 35
- Author names
- Martha Wells
- Genre
- Nonfiction
- Price
- 24.06 €
- Publisher
- —
- Active
- ✓
The Burning Door 36
- Author names
- Kim Robinson
- Genre
- Nonfiction
- Price
- 31.42 €
- Publisher
- Baen
- Active
- ✓
The Broken Mirror 37
- Author names
- Margaret Atwood and Octavia Butler
- Genre
- Nonfiction
- Price
- 7.28 €
- Publisher
- Tor Books
- Active
- ✓
The Silent Tower 39
- Author names
- Ann Leckie, Mary Shelley, and Ursula Le Guin
- Genre
- Nonfiction
- Price
- 25.60 €
- Publisher
- Baen
- Active
- ✓