1 class StoreController
< ApplicationController
3 @products = Product
.find_products_for_sale
8 product
= Product
.find(params
[:id])
10 @current_item = @cart.add_product(product
)
11 respond_to
do |format
|
12 format
.js
if request
.xhr
?
13 format
.html
{redirect_to_index
}
15 rescue ActiveRecord
::RecordNotFound
16 logger
.error("Attempt to access invalid product #{params[:id]}" )
17 redirect_to_index('Invalid product')
22 redirect_to_index
unless request
.xhr
?
28 session
[:cart] ||= Cart
.new
31 def redirect_to_index(msg
= nil)
32 flash
[:notice] = msg
if msg
33 redirect_to
:action => 'index'