diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index e41e2a43..46be2ef4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6bd9bc21..aac2a843 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5691,7 +5691,7 @@ end def download_named_attachment_url_without_domain(id, filename, option={}) attachment_id = (Attachment === id ? id.id : id) # Setting.protocol + "://" + Setting.host_name + "/attachments/download/" + attachment_id.to_s + "/" + filename - Setting.protocol + "://" + Setting.host_name + "/attachments/" + attachment_id.to_s + "/api/attachments/" + attachment_id.to_s end def named_attachment_url_without_domain(id, filename, option={}) diff --git a/app/views/libraries/_form.html.erb b/app/views/libraries/_form.html.erb index c71bc7c1..c5bb2ecd 100644 --- a/app/views/libraries/_form.html.erb +++ b/app/views/libraries/_form.html.erb @@ -73,7 +73,7 @@
- <% cover_url = cover_exists ? download_attachment_path(@library.cover_id) : '' %> + <% cover_url = cover_exists ? "/api/attachments/#{@library.cover.id}" : '' %>
diff --git a/app/views/libraries/_library_list.html.erb b/app/views/libraries/_library_list.html.erb index b5551966..4d5a52ab 100644 --- a/app/views/libraries/_library_list.html.erb +++ b/app/views/libraries/_library_list.html.erb @@ -2,7 +2,7 @@ <% if @libraries.present? %> <% @libraries.each do |library| %>
  • - <% image_url = library.cover.present? ? download_attachment_path(library.cover.id) : 'educoder/library-default-cover.png' %> + <% image_url = library.cover.present? ? "/api/attachments/#{library.cover.id}" : 'educoder/library-default-cover.png' %> <%= image_tag(image_url, width: 120, height: 90, class: 'mr15 mt3 radius4') %>

    diff --git a/app/views/managements/_training_item.html.erb b/app/views/managements/_training_item.html.erb index ceb1f055..50e856fa 100644 --- a/app/views/managements/_training_item.html.erb +++ b/app/views/managements/_training_item.html.erb @@ -8,7 +8,7 @@ <%= training.training_payinfo.try(:info) %> <% if training.training_payinfo.try(:attachment_id).present? %> - + <% end %> <%= format_time training.created_at %>