Commit 3a345f77

mo khan <mo@mokhan.ca>
2013-07-14 19:12:34
add route to api/v1/creations
1 parent c97f212
Changed files (2)
app
controllers
config
app/controllers/api/v1/creations_controller.rb
@@ -0,0 +1,21 @@
+module Api
+  module V1
+    class CreationsController < ApplicationController
+      before_filter :restrict_access
+      respond_to :json
+
+      def index
+        respond_with Creation.all
+      end
+
+      private
+
+      def restrict_access
+        authenticate_or_request_with_http_token do |token, options|
+          User.exists?(:authentication_token => token)
+        end
+      end
+
+    end
+  end
+end
config/routes.rb
@@ -58,4 +58,9 @@ Cake::Application.routes.draw do
 
   root :to => "creations#index"
 
+  namespace :api, :defaults => { :format => 'json' }  do
+    namespace :v1 do
+      resources :creations
+    end
+  end
 end