diff options
Diffstat (limited to 'app/controllers/api')
| -rw-r--r-- | app/controllers/api/v1/cakes_controller.rb | 16 | ||||
| -rw-r--r-- | app/controllers/api/v1/tutorials_controller.rb | 5 |
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 |
