Books

How this page is built the gem renders it — this is all you write

A full table — search, an inline filter row, sortable columns and row actions — all derived from the model. This page toggles between the curated :index and the fuller :catalog fieldset (currently :catalog). Your controller assigns @books — scope it for authorization (e.g. Book.accessible_by(current_ability)) and the gem renders that scope.

app/models/book.rb
crud_structure do
  attribute :price, as: :number, unit: '€', digits: 2
  fieldset :index,   %i[cover title author_names genre price publisher active]
  fieldset :catalog, %i[cover title subtitle author_names genre price purchase_price
                        shop_margin pages published_on publisher reviews active manual created_at]
end
app/views/books/index.html.erb
<%= crud_collection @books, fieldset: :catalog %>   <%# search, filters, sort, actions %>
<%= crud_filter   Book, fieldset: :catalog %>     <%# filter sidebar (takes the model, not a scope) %>

Read more: Fields & cells  ·  Views & fieldsets

Reset
Cover Title Subtitle Author names Genre Price Pages Published on Publisher Reviews Active Manual Created at
Reset
The Ancient Tower 11 A novel of the Engine Ted Chiang, Ann Leckie, and Frank Herbert Fiction 40.82 € 263 2022-12-27 Gollancz Linus on The Ancient Tower 11, Radia on The Ancient Tower 11, Barbara on The Ancient Tower 11 +1 more 17 Aug 16:08
The Dispossessed Ocean 67 Martha Wells Fiction 40.62 € 626 2022-10-02 Tor Books Linus on The Dispossessed Ocean 67, Ada on The Dispossessed Ocean 67 17 Aug 16:08
The Hidden Signal 85 A novel of the Station Becky Chambers, Liu Cixin, and Margaret Atwood Fiction 20.30 € 689 1987-02-03 Ace Grace on The Hidden Signal 85, Edsger on The Hidden Signal 85, Donald on The Hidden Signal 85 the-hidden-signal-85-manual.pdf 17 Aug 16:08
The Broken Mirror 96 A novel of the City Stanisław Lem Fiction 34.38 € 147 2015-03-05 Vintage Linus on The Broken Mirror 96 17 Aug 16:08
Filter
Cover
Title
Subtitle
Author names
Genre
Price
Pages
Published on
Publisher
Active
Manual
Created at
Blurb
Reset