diff options
| author | mo khan <mo@mokhan.ca> | 2014-10-31 22:52:02 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-10-31 22:52:02 -0600 |
| commit | fd68d4545d314535caf4d975a96a98a310480821 (patch) | |
| tree | 21dd3f25287104fad46b3b588f354774e8d1facb /app/controllers/api/v1 | |
| parent | 857cb13f618a6dd396eb6047b43ddd6347bc37dc (diff) | |
add tools to cake edit page.
Diffstat (limited to 'app/controllers/api/v1')
| -rw-r--r-- | app/controllers/api/v1/cakes_controller.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/controllers/api/v1/cakes_controller.rb b/app/controllers/api/v1/cakes_controller.rb index 7dc46473..862ef071 100644 --- a/app/controllers/api/v1/cakes_controller.rb +++ b/app/controllers/api/v1/cakes_controller.rb @@ -24,15 +24,14 @@ 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) + current_user.tag(@cake, with: params[:cake][:tools], on: :tools) + if @cake.update(cake_params.reject { |key, value| key == "tags" || key == "tools" }) + respond_with @cake + else + respond_with @cake + end end def destroy |
