shopping cart

This commit is contained in:
Karol Selak 2021-03-22 02:25:17 +01:00
parent 733870ce96
commit df7585c5e1
11 changed files with 79 additions and 11 deletions

View file

@ -24,8 +24,8 @@
<%= book.quantity %>
</div>
<div class='col s2'>
<% if logged_in? && book.quantity.positive? %>
<%= link_to 'Add', edit_book_path(book), class: "btn" %>
<% if logged_in? && book.quantity.positive? && !current_user.books.exists?(book.id) %>
<%= link_to 'Add', "book/#{book.id}/add_to_cart", method: :post, class: "btn" %>
<% end %>
</div>