Commit 19fecb1d

mo khan <mo@mokhan.ca>
2014-11-19 04:38:42
start v2 of the api for ember.
1 parent 9e6e751
Changed files (4)
app
controllers
views
config
app/controllers/api/v2/cakes_controller.rb
@@ -0,0 +1,9 @@
+module Api
+  module V2
+    class CakesController < ApplicationController
+      def index
+        @cakes = Creation.all
+      end
+    end
+  end
+end
app/views/api/v2/cakes/index.json.jbuilder
@@ -0,0 +1,7 @@
+json.cakes @cakes do |cake|
+  json.id cake.id
+  json.name cake.name
+  json.description cake.story
+  json.created_at cake.created_at
+  json.updated_at cake.updated_at
+end
config/application.rb
@@ -33,17 +33,17 @@ module Cake
     # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
     # config.i18n.default_locale = :de
 
-    config.middleware.use ExceptionNotification::Rack, :email => {
-      :email_prefix => "[Boom! #{Rails.env}] ",
-      :sender_address => %{"notifier" <notifier@cakeside.com>},
-      :exception_recipients => ENV['EXCEPTION_EMAIL_ADDRESS'].split(" "),
-    } unless Rails.env.test?
-    config.middleware.use Rack::Attack
     config.middleware.use Rack::Cors do
       allow do
         origins "*"
         resource "*", headers: :any, methods: [:get, :post, :put, :delete, :options]
       end
     end
+    config.middleware.use ExceptionNotification::Rack, :email => {
+      :email_prefix => "[Boom! #{Rails.env}] ",
+      :sender_address => %{"notifier" <notifier@cakeside.com>},
+      :exception_recipients => ENV['EXCEPTION_EMAIL_ADDRESS'].split(" "),
+    } unless Rails.env.test?
+    config.middleware.use Rack::Attack
   end
 end
config/routes.rb
@@ -67,6 +67,9 @@ Cake::Application.routes.draw do
       resources :profiles, only: [:show, :update]
       resources :logins, only: [:create]
     end
+    namespace :v2 do
+      resources :cakes, only: [:index]
+    end
   end
 
   namespace :admin do