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 Garden 15 | Ada | ★★★☆☆ | Slow start, great finish. A classic in the making. | 30 Jun 12:07 | |
| The Endless Garden 15 | Grace | ★★☆☆☆ | A classic in the making. | 30 Jun 12:07 | |
| The Endless Garden 15 | Radia | ★★★★★ | Slow start, great finish. The world-building is superb. | 30 Jun 12:07 | |
| The Endless Garden 15 | Ada | ★★☆☆☆ | Not my cup of tea. Could not put it down. | 30 Jun 12:07 | |