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