修改课程资源排序报错

course_group
sw 11 years ago
parent 19b61118ac
commit 192a2f8549

@ -133,9 +133,9 @@ class FilesController < ApplicationController
end end
if order_by.count == 1 if order_by.count == 1
sort += "#{Attachment.table_name}.#{attribute} asc " sort += "#{Attachment.table_name}.#{attribute} asc " if attribute
elsif order_by.count == 2 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 end
if sort_type != params[:sort].split(",").last if sort_type != params[:sort].split(",").last
sort += "," sort += ","
@ -176,16 +176,19 @@ class FilesController < ApplicationController
end end
@sort = order_by[0] @sort = order_by[0]
@order = order_by[1] @order = order_by[1]
if order_by.count == 1 if order_by.count == 1 && attribute
sort += "#{Attachment.table_name}.#{attribute} asc " sort += "#{Attachment.table_name}.#{attribute} asc "
elsif order_by.count == 2 if sort_type != params[:sort].split(",").last
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " sort += ","
end end
elsif order_by.count == 2 && order_by[1]
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
if sort_type != params[:sort].split(",").last if sort_type != params[:sort].split(",").last
sort += "," sort += ","
end end
end end
end end
end
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]

Loading…
Cancel
Save