cart summary and refactoring
This commit is contained in:
parent
df7585c5e1
commit
c63c6bc448
4 changed files with 20 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue