Second Commit
This commit is contained in:
22
app/views/books/_book.html.erb
Normal file
22
app/views/books/_book.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="col-lg-4 mb-4" id="book_<%= book.id%>">
|
||||
<div class="card h-100 shadow-sm">
|
||||
<h4 class="card-header"><%= book.title %></h4>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
<span> <%= book.description %> </span>
|
||||
</div>
|
||||
<% if current_user %>
|
||||
<div class="card-footer">
|
||||
<% if book.available_copies > 0 %>
|
||||
<% unless current_user.books.include?book %>
|
||||
<%= link_to 'Borrow', borrow_path(book), class: "btn btn-success", remote: true %>
|
||||
<% else %>
|
||||
<%= link_to 'Borrowed', 'javascript:;', class: "btn btn-primary", remote: true %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<a href="javascript:;" class= "btn btn-secondary">Not available</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
5
app/views/books/index.html.erb
Normal file
5
app/views/books/index.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1 class="my-4">The complete list of all books</h1>
|
||||
<div class="row">
|
||||
<%= render partial: 'books/book', collection: @books%>
|
||||
</div>
|
||||
<%= paginate @books, theme: 'twitter-bootstrap-4' %>
|
||||
Reference in New Issue
Block a user