We Recommend

The Rails Way The Rails Way
Now, for the first time, there’s a comprehensive, authoritative guide to building production-quality software with Rails. Pioneering Rails developer Obie Fernandez and a team of experts illuminate the entire Rails API, along with the Ruby idioms, design approaches, libraries, and plug-ins that make Rails so valuable.


Posted By

winson on 04/30/07


Tagged

textmate controller cart


Versions (?)


My add book to cart


Published in: Rails 


  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 

You need to login to post a comment.