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 Silent Tower 3 | Linus | ★★★★★ | Not my cup of tea. Read it twice already. | 29 Jun 01:16 | |
| The Silent Tower 3 | Linus | ★★★★★ | Not my cup of tea. | 29 Jun 01:16 | |
| The Silent Tower 3 | Ada | ★★★★☆ | Could not put it down. | 29 Jun 01:16 | |
| The Silent Tower 3 | Grace | ★★★★☆ | Not my cup of tea. | 29 Jun 01:16 | |