Improve the book listing...
Add order_by. Prefetch author and show author's name. Add table markup.
This commit is contained in:
parent
143dcc9bdc
commit
8dcdb9fb10
|
@ -12,7 +12,11 @@ sub count_all ($self) {
|
|||
sub get_page ($self, $page_number = 1) {
|
||||
my $rs = $self->schema->resultset('Book')->search_rs(
|
||||
undef,
|
||||
{ page => $page_number, rows => 10 },
|
||||
{ prefetch => [ "author" ],
|
||||
order_by => [ "me.name " ],
|
||||
page => $page_number,
|
||||
rows => 10,
|
||||
},
|
||||
);
|
||||
return $rs;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,17 @@ Book count is <%= $book_count %>.
|
|||
|
||||
<p/>
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Book</th><th>Author</th>
|
||||
</tr>
|
||||
% for my $book ($book_page->all) {
|
||||
<%= $book->name %><br/>
|
||||
<tr>
|
||||
<td><%= $book->name %></td>
|
||||
<td><%= $book->author->name %>
|
||||
</td></tr>
|
||||
% }
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p/>
|
||||
|
|
Loading…
Reference in New Issue