changelog shortlog tags manifest raw

changeset: 'Add to Cart'をorder_items resourceへのPOSTとみなす。

changeset 19: a995025031b3
parent 18:b97ed3573af2
tag:tip
author: moriq <moriq@moriq.com>
date: Mon Mar 10 11:04:49 2008 +0900 (16 years ago)
files: app/controllers/order_items_controller.rb app/controllers/orders_controller.rb app/views/products/show.html.erb
description: 'Add to Cart'をorder_items resourceへのPOSTとみなす。
--- a/app/controllers/order_items_controller.rb	Mon Mar 10 10:39:23 2008 +0900
+++ b/app/controllers/order_items_controller.rb	Mon Mar 10 11:04:49 2008 +0900
@@ -91,6 +91,7 @@ class OrderItemsController < Application
 	@order = Order.find(session[:order_id])
       else
 	@order = Order.create
+        session[:order_id] = @order.id
       end
     end
 end
--- a/app/controllers/orders_controller.rb	Mon Mar 10 10:39:23 2008 +0900
+++ b/app/controllers/orders_controller.rb	Mon Mar 10 11:04:49 2008 +0900
@@ -80,6 +80,7 @@ class OrdersController < ApplicationCont
 	@order = Order.find(session[:order_id])
       else
 	@order = Order.create
+        session[:order_id] = @order.id
       end
     end
 end
--- a/app/views/products/show.html.erb	Mon Mar 10 10:39:23 2008 +0900
+++ b/app/views/products/show.html.erb	Mon Mar 10 11:04:49 2008 +0900
@@ -9,5 +9,6 @@
 </p>
 
 
+<%= link_to 'Add to Cart', order_items_path(:order_item => { :product_id => @product.id, :quantity => 1 }), :method => :post %> |
 <%= link_to 'Edit', edit_product_path(@product) %> |
 <%= link_to 'Back', products_path %>