From 192a2f8549472d00180e468b883ac033d6223c57 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Dec 2014 14:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8E=92=E5=BA=8F=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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