<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/jokes/checkout.html.erb</filename>
    </added>
    <added>
      <filename>app/views/jokes/my.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -12,7 +12,18 @@ class JokesController &lt; ApplicationController
       format.xml  { render :xml =&gt; @jokes }
     end
   end
-
+  
+  # GET /jokes/my
+  # GET /jokes/my.xml
+  def my
+    @purchases = current_user.company.purchases
+    
+    respond_to do |format|
+      format.html # index.html.erb
+      format.xml  { render :xml =&gt; @jokes }
+    end
+  end
+  
   # GET /jokes/1
   # GET /jokes/1.xml
   def show
@@ -40,6 +51,34 @@ class JokesController &lt; ApplicationController
     @joke = Joke.find(params[:id])
   end
 
+  # GET /jokes/1/checkout
+  # GET /jokes/1/checkout.xml
+  def checkout
+    create_purchase
+
+    respond_to do |format|
+      format.html # show.html.erb
+      format.xml  { render :xml =&gt; @joke }
+    end
+  end
+  
+  # POST /jokes/1/purchase
+  # POST /jokes/1/purchase.xml
+  def purchase
+    create_purchase
+
+    respond_to do |format|
+      if @purchase.save
+        flash[:notice] = 'Joke was successfully purchased.'
+        format.html { redirect_to(@purchase.joke) }
+        format.xml  { render :xml =&gt; @purchase.joke, :status =&gt; :created, :location =&gt; @purchase.joke }
+      else
+        format.html { render :action =&gt; &quot;checkout&quot; }
+        format.xml  { render :xml =&gt; @purchase.errors, :status =&gt; :unprocessable_entity }
+      end
+    end
+  end
+
   # POST /jokes
   # POST /jokes.xml
   def create
@@ -85,4 +124,13 @@ class JokesController &lt; ApplicationController
       format.xml  { head :ok }
     end
   end
+  
+  
+private
+  def create_purchase
+    @purchase = Purchase.new
+    @purchase.joke = Joke.find(params[:id])
+    @purchase.user = current_user
+    @purchase.company = current_user.company
+  end
 end</diff>
      <filename>app/controllers/jokes_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 ActionController::Routing::Routes.draw do |map|
-  map.resources :jokes
+  map.resources :jokes, :member =&gt; { :checkout =&gt; :get, :purchase =&gt; :post }, :collection =&gt; { :my =&gt; :get }
 
   map.resources :companies
 </diff>
      <filename>config/routes.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>762276bc3315b68b6eca02521a1a06fa9889f429</id>
    </parent>
  </parents>
  <author>
    <name>Martin Kleppmann</name>
    <email>martin@eptcomputing.com</email>
  </author>
  <url>http://github.com/ept/cracktastic/commit/09d0ff52ac0644bf0c496d0a1a1b86f4dc0d72fc</url>
  <id>09d0ff52ac0644bf0c496d0a1a1b86f4dc0d72fc</id>
  <committed-date>2009-04-14T10:08:20-07:00</committed-date>
  <authored-date>2009-04-14T08:35:07-07:00</authored-date>
  <message>Implemented purchasing process</message>
  <tree>b4ece5bf15a9c9f78fe59b6c4fd833832c9de898</tree>
  <committer>
    <name>Martin Kleppmann</name>
    <email>martin@eptcomputing.com</email>
  </committer>
</commit>
