lib/controllers/concerns/sortable.rb in opale-0.1.4 vs lib/controllers/concerns/sortable.rb in opale-0.1.31
- old
+ new
@@ -1,7 +1,7 @@
# Concern for sorting models
-module Sort
+module Sortable
extend ActiveSupport::Concern
included do
before_action :sort
end
@@ -10,17 +10,21 @@
def sort
return if params['searching'].nil?
@search_hash = Array.new
- objects = Array.new
+ objects = Array.new
params.each do |k, v|
unless v.class.eql? String
objects << k
@search_hash << v
end
end
+
+ puts objects.inspect
+
+ return if objects.nil? || objects.empty?
# If the object is inside a namespace
if objects[0].include? '::'
to_capitalize = objects[0].split('::')
# We split the string with '::' and camelize the two words