cart summary and refactoring

This commit is contained in:
Karol Selak 2021-03-22 02:49:05 +01:00
parent df7585c5e1
commit c63c6bc448
4 changed files with 20 additions and 8 deletions

View file

@ -1,2 +1,8 @@
module BooksHelper
def cart_summary
number_to_currency(@books.map{ |b| b.price }.reduce(:+))
end
def can_book_be_added?(book)
logged_in? && book.quantity.positive? && !current_user.books.exists?(book.id)
end
end