Title
Authors
Price
Quantity
<% @books.each do |book| %>
<%= link_to book.title, book %>
<%= book.authors %>
<%= book.price_with_currency %>
<%= book.quantity %>
<% 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 %>
<% if current_user&.admin? %>
<%= book.published ? 'published' : 'unpublished' %>
<%= link_to 'Edit', edit_book_path(book), class: "btn" %>
<% end %>
<% end %>