How this page is built
the gem renders it — this is all you write
“Cards” is a custom layout you add — the gem ships only the built-in :table. Drop one partial that receives the same collection presenter (still driven by the :index fieldset) and arrange the markup however you like; the gem still derives the fields, cells, filtering, sorting and actions for you. A card grid has no column headers, so crud_filter takes sort: true to carry the sort picker.
app/views/crud_components/layouts/_cards.html.erb
<% collection.records.each do |record| %>
<div class="card card-body">
<% collection.fields.each do |f| %><%= collection.cell(f, record) %><% end %>
</div>
<% end %>
app/views/books/index.html.erb
<%= crud_collection @books, fieldset: :index, layout: :cards %>
<%= crud_filter Book, fieldset: :index, sort: true %> <%# headerless → carry the sort picker %>
Read more: Add a layout · Views
The Broken Archive 1
- Author names
- Frank Herbert, Ted Chiang, and Ann Leckie
- Genre
- Nonfiction
- Price
- 9.59 €
- Publisher
- Orbit
- Active
- ✓
The Broken Garden 6
- Author names
- Stanisław Lem, Ursula Le Guin, and Iain Banks
- Genre
- Nonfiction
- Price
- 19.85 €
- Publisher
- Orbit
- Active
- ✓
The Endless Garden 15
- Author names
- Ursula Le Guin, Joe Abercrombie, and Adrian Tchaikovsky
- Genre
- Nonfiction
- Price
- 29.85 €
- Publisher
- Orbit
- Active
- ✓