de9e160be607cd54c7522ee77ad512f3ffa2640c
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 redirect_to_index("Your cart is empty" )
31 respond_to
do |format
|
32 format
.js
if request
.xhr
?
40 @order = Order
.new(params
[:order])
41 @order.add_line_items_from_cart(@cart)
44 redirect_to_index("Thank you for your order")
46 render
:action => 'checkout'
54 session
[:cart] ||= Cart
.new
57 def redirect_to_index(msg
= nil)
58 flash
[:notice] = msg
if msg
59 redirect_to
:action => 'index'