diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 1ed40f691..41518e2f1 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -133,9 +133,9 @@ class FilesController < ApplicationController end if order_by.count == 1 - sort += "#{Attachment.table_name}.#{attribute} asc " + sort += "#{Attachment.table_name}.#{attribute} asc " if attribute elsif order_by.count == 2 - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] end if sort_type != params[:sort].split(",").last sort += "," @@ -176,13 +176,16 @@ class FilesController < ApplicationController end @sort = order_by[0] @order = order_by[1] - if order_by.count == 1 + if order_by.count == 1 && attribute sort += "#{Attachment.table_name}.#{attribute} asc " - elsif order_by.count == 2 + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " - end - if sort_type != params[:sort].split(",").last - sort += "," + if sort_type != params[:sort].split(",").last + sort += "," + end end end end