My add book to cart


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def add
  2. book = Book.find(params[:id]) or raise ActiveRecord::RecordNotFound
  3. # Added by sending book object.
  4. flash[:cart_notice] = "'#{book.title}' was added!" if @cart.add book
  5. redirect_to :action => 'index'
  6. end

Report this snippet


Comments


You need to login to view comments.