Commit a5db20d0

mo khan <mo@mokhan.ca>
2014-07-02 04:41:24
add destroy route to remove a cake via the api.
1 parent d8dd92a
Changed files (2)
app
controllers
config
app/controllers/api/v1/cakes_controller.rb
@@ -35,6 +35,11 @@ module Api
         respond_with(@cake = cake)
       end
 
+      def destroy
+        current_user.creations.find(params[:id]).destroy!
+        render nothing: true
+      end
+
       private
 
       def cake_params
config/routes.rb
@@ -46,7 +46,7 @@ Cake::Application.routes.draw do
 
   namespace :api, :defaults => { :format => 'json' }  do
     namespace :v1 do
-      resources :cakes, only: [:index, :show, :create, :update] do
+      resources :cakes, only: [:index, :show, :create, :update, :destroy] do
         resources :photos, only: [:index, :show, :create]
       end
       resources :categories, only: [:index]