/
index.html.erb
43 lines (38 loc) · 1.04 KB
/
index.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<p id="notice"><%= notice %></p>
<h1>Books</h1>
<table>
<thead>
<tr>
<th>Isbn</th>
<th>Title</th>
<th>Year published</th>
<th>Author</th>
<th>Categories</th>
<th>Recommendations</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @books.each do |book| %>
<tr>
<td><%= book.isbn %></td>
<td><%= book.title %></td>
<td><%= book.year_published %></td>
<td><%= book.author.try(:name) %></td>
<td>
<ul>
<% book.categories.each do |category| %>
<li><%= link_to category.name, category %></li>
<% end %>
</ul>
</td>
<td><%= (@recommendations[book.isbn] || []).map(&:title).to_sentence %></td>
<td><%= link_to 'Show', book %></td>
<td><%= link_to 'Edit', edit_book_path(book) %></td>
<td><%= link_to 'Destroy', book, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Book', new_book_path %>