Authors
How this page is built
the gem renders it — this is all you write
A zero-config model — Author doesn't even include CrudComponents::Model. The table, search, filters, the derived actions and the auto-derived Books (habtm) column are all inferred from the schema. Your controller just assigns the scope @authors (where you'd authorize).
app/models/author.rb
class Author < ApplicationRecord
has_and_belongs_to_many :books
end # no CrudComponents config at all
app/views/authors/index.html.erb
<%= crud_collection @authors %>
| Id | Name | Created at | Updated at | Images | Books | ||
|---|---|---|---|---|---|---|---|
|
|
|
|
|
||||
| 31 | Ursula Le Guin | ursula@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |
| 32 | Joe Abercrombie | joe@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |
| 33 | Ann Leckie | ann@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |
| 34 | Frank Herbert | frank@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |
| 35 | Iain Banks | iain@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |
| 36 | Octavia Butler | octavia@example.com | 27 Jun 15:29 | 27 Jun 15:29 | — | — | |