summaryrefslogtreecommitdiff
path: root/app/controllers/api
diff options
context:
space:
mode:
authormo k <mo.khan@gmail.com>2014-11-22 21:35:38 -0700
committermo k <mo.khan@gmail.com>2014-11-22 21:35:38 -0700
commit7620674929c024a7279dfa116deab8805f2fb2ec (patch)
tree38e5daa58e646a1907765def9c64d2f7a56b5fe9 /app/controllers/api
parent31b5a3cf55d273dfc93385be8cf28ce1f8f8abd2 (diff)
parent66c09b81c3a4baeb0ca39a1e87496cca53a43a7c (diff)
Merged in mocheen/cakeside/cake-uploads (pull request #117)
add tools to cake edit page.
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/cakes_controller.rb16
-rw-r--r--app/controllers/api/v1/tutorials_controller.rb5
2 files changed, 8 insertions, 13 deletions
diff --git a/app/controllers/api/v1/cakes_controller.rb b/app/controllers/api/v1/cakes_controller.rb
index 7dc46473..1f03e8ee 100644
--- a/app/controllers/api/v1/cakes_controller.rb
+++ b/app/controllers/api/v1/cakes_controller.rb
@@ -24,15 +24,13 @@ module Api
end
def update
- UpdateCakeCommand.new(self).run(params[:id], params[:cake][:tags], cake_params)
- end
-
- def update_cake_succeeded(cake)
- respond_with(@cake = cake)
- end
-
- def update_cake_failed(cake)
- respond_with(@cake = cake)
+ @cake = current_user.creations.find(params[:id])
+ current_user.tag(@cake, with: params[:cake][:tags], on: :tags)
+ if @cake.update(cake_params.reject { |key, value| key == "tags" })
+ respond_with @cake
+ else
+ respond_with @cake
+ end
end
def destroy
diff --git a/app/controllers/api/v1/tutorials_controller.rb b/app/controllers/api/v1/tutorials_controller.rb
index c257f707..8c75dbf0 100644
--- a/app/controllers/api/v1/tutorials_controller.rb
+++ b/app/controllers/api/v1/tutorials_controller.rb
@@ -1,16 +1,13 @@
module Api
module V1
class TutorialsController < ApiController
- respond_to :json
-
def index
- respond_with(@tutorials = current_user.tutorials)
+ @tutorials = current_user.tutorials.page(page).per(per_page)
end
def create
@tutorial = current_user.tutorials.create!(tutorial_params)
current_user.tag(@tutorial, with: params[:tutorial][:tags], on: :tags)
- respond_with(@tutorial)
end
private