|
|
|
@ -359,7 +359,7 @@ class AttachmentsController < ApplicationController
|
|
|
|
|
saved = @attachment.save
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.json { render json: { attachment_id: @attachment.id, url: download_attachment_path(@attachment.id) } }
|
|
|
|
|
format.json { render json: { attachment_id: @attachment.id, url: "/api/attachments/#{@attachment.id}"} }
|
|
|
|
|
format.api {
|
|
|
|
|
if saved
|
|
|
|
|
render :action => 'upload', :status => :created
|
|
|
|
@ -380,7 +380,7 @@ class AttachmentsController < ApplicationController
|
|
|
|
|
render json: {
|
|
|
|
|
success: saved ? 1 : 0, # | 1, // 0 表示上传失败,1 表示上传成功
|
|
|
|
|
message: "上传信息:#{ @attachment.errors.full_messages.join(',') }",
|
|
|
|
|
url: download_attachment_path(@attachment.id), # 上传成功时才返回
|
|
|
|
|
url: "/api/attachments/#{@attachment.id}", # 上传成功时才返回
|
|
|
|
|
attachment_id: @attachment.id
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
@ -413,7 +413,7 @@ class AttachmentsController < ApplicationController
|
|
|
|
|
render json: {
|
|
|
|
|
success: saved ? 1 : 0, # | 1, // 0 表示上传失败,1 表示上传成功
|
|
|
|
|
message: "上传失败:#{ @attachment.errors.full_messages.join(',') }",
|
|
|
|
|
url: download_attachment_path(@attachment.id) # 上传成功时才返回
|
|
|
|
|
url: "/api/attachments/#{@attachment.id}" # 上传成功时才返回
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|