From 213f74e9375ed70f6002408dde2412b793d500a8 Mon Sep 17 00:00:00 2001 From: Oliver Luethi Date: Thu, 31 Mar 2016 11:07:26 +0200 Subject: [PATCH] Added REST-API support for updating attachments --- app/controllers/attachments_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3f304d0..79e2257 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController before_filter :delete_authorize, :only => :destroy before_filter :authorize_global, :only => :upload - accept_api_auth :show, :download, :thumbnail, :upload, :destroy + accept_api_auth :show, :download, :thumbnail, :upload, :update, :destroy def show respond_to do |format| @@ -107,11 +107,17 @@ class AttachmentsController < ApplicationController def update if params[:attachments].is_a?(Hash) if Attachment.update_attachments(@attachments, params[:attachments]) - redirect_back_or_default home_path - return + respond_to do |format| + format.html { redirect_back_or_default home_path } + format.api { render_api_ok } + end + return end end - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.api { render_validation_errors(@attachments) } + end end def destroy -- 1.9.4.msysgit.2