From 5281464af47abfef4bfb0abc3be0c9331a67ada9 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sat, 11 Aug 2012 16:56:28 +0800 Subject: [PATCH] Fix bug for sorting when there's only one category with elements --- app/controllers/orbit_backend_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 6bc42ec9..b43a6b9a 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -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!