Reviews
How this page is built
the gem renders it — this is all you write
The rating column uses a custom renderer — one partial in your app (_stars.html.erb) named by as: :stars. Search delegates through :book into Book's own search_in (try a publisher name). Your controller assigns @reviews.
app/models/review.rb
crud_structure do
search_in :reviewer_name, :body, :book # :book delegates into Book's search_in
attribute :rating, as: :stars # → app/views/crud_components/fields/_stars.html.erb
fieldset :index, %i[book reviewer_name rating body created_at]
end
app/views/reviews/index.html.erb
<%= crud_collection @reviews %>
Read more: Renderers · The like-spec
|
|
|||||
|---|---|---|---|---|---|
| Book | Reviewer name | Rating | Body | Created at | |
|
|
|
||||
| The Endless Mirror 20 | Ada | ★★★★☆ | The world-building is superb. | 30 Jun 12:07 | |
| The Endless Mirror 20 | Barbara | ★★★★★ | Not my cup of tea. | 30 Jun 12:07 | |
| The Endless Mirror 20 | Donald | ★★☆☆☆ | The world-building is superb. A classic in the making. | 30 Jun 12:07 | |
| The Endless Mirror 20 | Grace | ★★☆☆☆ | The world-building is superb. | 30 Jun 12:07 | |