修改课程资源排序报错

This commit is contained in:
sw 2014-12-04 14:53:53 +08:00
parent 19b61118ac
commit 192a2f8549
1 changed files with 10 additions and 7 deletions

View File

@ -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,14 +176,17 @@ 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
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
end
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]} "
if sort_type != params[:sort].split(",").last
sort += ","
end
end
end
end