From fd676f13b59961b8a762de07790fee26ca968e8b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 10 Mar 2015 21:50:47 +0800 Subject: [PATCH] =?UTF-8?q?#994=20=20=E4=BD=9C=E5=93=81=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=EF=BC=9A=E8=B5=84=E6=BA=90=E6=8E=92=E5=BA=8F=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 474f199a2..7638949ba 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -143,11 +143,16 @@ class FilesController < ApplicationController end end - @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] - @containers += @project.versions.includes(:attachments).reorder(sort).all + @containers = [ Project.includes(:attachments).find(@project.id)] + @containers += @project.versions.includes(:attachments).all - show_attachments @containers + ids = [] + @containers.each do |c| + ids += c.attachments.pluck(:id) + end + @containers = [Struct.new(:attachments).new(Attachment.where('id in (?)',ids).reorder(sort))] + show_attachments @containers respond_to do |format| format.html