Fix bug for sorting when there's only one category with elements

This commit is contained in:
Christophe Vilayphiou 2012-08-11 16:56:28 +08:00
parent 2bd132cef9
commit 5281464af4
1 changed files with 1 additions and 1 deletions

View File

@ -103,7 +103,7 @@ class OrbitBackendController< ApplicationController
referenced_objects = object_class.find(referer_ids) rescue nil
if referenced_objects
a = Array.new
referenced_objects.each { |referer| a << [get_string_value_from_object(referer), referer.id] }
referenced_objects.to_a.each { |referer| a << [get_string_value_from_object(referer), referer.id] }
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
sorted_objects = sorted.collect {|x| objects.where(option => x[1]).entries }
sorted_objects.flatten!