<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,7 +9,7 @@ class OrdersController &lt; Spree::BaseController
   
   helper :products
 
-  create.after do    
+  create.before do    
     params[:products].each do |product_id,variant_id|
       quantity = params[:quantity].to_i if !params[:quantity].is_a?(Array)
       quantity = params[:quantity][variant_id].to_i if params[:quantity].is_a?(Array)
@@ -20,9 +20,7 @@ class OrdersController &lt; Spree::BaseController
       quantity = quantity.to_i
       @order.add_variant(Variant.find(variant_id), quantity) if quantity &gt; 0
     end if params[:variants]
-    
-    @order.save
-    
+
     # store order token in the session
     session[:order_token] = @order.token
   end
@@ -30,15 +28,17 @@ class OrdersController &lt; Spree::BaseController
   # override the default r_c behavior (remove flash - redirect to edit details instead of show)
   create do
     flash nil 
-    wants.html {redirect_to edit_order_url(@order)}
+		success.wants.html {redirect_to edit_order_url(@order)}
+		failure.wants.html { render :template =&gt; &quot;orders/edit&quot; }
   end     
-  
+
   # override the default r_c flash behavior
-  update.flash nil
-  update.response do |wants| 
-    wants.html {redirect_to edit_order_url(object)}
+  update do  
+		flash nil
+		success.wants.html { redirect_to edit_order_url(object) }
+		failure.wants.html { render :template =&gt; &quot;orders/edit&quot; }
   end  
-
+ 
   #override r_c default b/c we don't want to actually destroy, we just want to clear line items
   def destroy
     flash[:notice] = I18n.t(:basket_successfully_cleared)
@@ -60,13 +60,13 @@ class OrdersController &lt; Spree::BaseController
   end
     
   private
-  def build_object        
+  def build_object
     @object ||= find_order
   end
   
   def object 
-    return Order.find_by_number(params[:id]) if params[:id]
-    find_order
+  	@object ||= Order.find_by_number(params[:id]) if params[:id]
+		return @object || find_order
   end   
   
   def prevent_editing_complete_order      </diff>
      <filename>app/controllers/orders_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class LineItem &lt; ActiveRecord::Base
   validates_numericality_of :quantity, :only_integer =&gt; true, :message =&gt; &quot;must be an integer&quot;
   validates_numericality_of :price
 
-  attr_accessible :quantity
+  attr_accessible :quantity, :variant_id, :order_id
 
   def copy_price
     self.price = variant.price if variant &amp;&amp; self.price.nil?</diff>
      <filename>app/models/line_item.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,8 +41,7 @@ class Order &lt; ActiveRecord::Base
   delegate :email, :to =&gt; :checkout
   delegate :ip_address, :to =&gt; :checkout
   delegate :special_instructions, :to =&gt; :checkout 
-  
-  validates_associated :line_items, :message =&gt; &quot;are not valid&quot;
+
   validates_numericality_of :item_total
   validates_numericality_of :total
 </diff>
      <filename>app/models/order.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+&lt;%= error_messages_for :order  %&gt;
 &lt;table id=&quot;cart&quot;&gt;
   &lt;thead&gt;
     &lt;tr&gt;      </diff>
      <filename>app/views/orders/_form.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 &lt;tr class=&quot;&lt;%= cycle('', 'alt') %&gt;&quot;&gt;
   &lt;td&gt;
+    &lt;%= item_form.hidden_field :variant_id %&gt;
+    &lt;%= item_form.hidden_field :order_id %&gt;
     &lt;% if variant.images.length == 0 %&gt;
       &lt;%= small_image(variant.product) %&gt;
     &lt;% else %&gt;</diff>
      <filename>app/views/orders/_line_item.html.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>40c5598ece6b20d0f270a5fe9519c8b618054e48</id>
    </parent>
  </parents>
  <author>
    <name>Brian Quinn</name>
    <email>briandquinn@gmail.com</email>
  </author>
  <url>http://github.com/railsdog/spree/commit/14f5c79b6c0dc71dca2314a1caabf0c66d328477</url>
  <id>14f5c79b6c0dc71dca2314a1caabf0c66d328477</id>
  <committed-date>2009-11-04T10:23:10-08:00</committed-date>
  <authored-date>2009-11-04T10:23:10-08:00</authored-date>
  <message>Ensure AR errors are displayed on add/update of cart

[#862 state:resolved]</message>
  <tree>f12af0e50e40b1b92b623ff13df3b359898a733b</tree>
  <committer>
    <name>Brian Quinn</name>
    <email>briandquinn@gmail.com</email>
  </committer>
</commit>
