Finished Chapter 12
[depot.git] / app / controllers / info_controller.rb
diff --git a/app/controllers/info_controller.rb b/app/controllers/info_controller.rb
new file mode 100644 (file)
index 0000000..85d870e
--- /dev/null
@@ -0,0 +1,17 @@
+class InfoController < ApplicationController
+  def who_bought
+    @product = Product.find(params[:id])
+    @orders = @product.orders
+    respond_to do |format|
+      format.html
+      format.xml  {render :layout => false}
+      format.atom {render :layout => false}
+      format.json {render :layout => false, :json => @product.to_json(:include => :orders) }
+    end
+  end
+
+protected
+
+  def authorize
+  end
+end