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.
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 %>
Read more: Add a layout · Views
The Endless Signal 50
- Author names
- Mary Shelley, Ursula Le Guin, and Ted Chiang
- Genre
- Nonfiction
- Price
- 26.36 €
- Publisher
- Tor Books
- Active
- ✓
The Dispossessed Door 51
- Author names
- Stanisław Lem and Becky Chambers
- Genre
- Nonfiction
- Price
- 36.10 €
- Publisher
- Tor Books
- Active
- ✓
The Broken Ocean 68
- Author names
- Kim Robinson and Stanisław Lem
- Genre
- Nonfiction
- Price
- 6.07 €
- Publisher
- Tor Books
- Active
- ✗
The Burning Garden 103
- Author names
- Stanisław Lem and Iain Banks
- Genre
- Nonfiction
- Price
- 38.50 €
- Publisher
- Tor Books
- Active
- ✓