diff --git a/lib/ransack/adapters/mongoid/ransack/visitor.rb b/lib/ransack/adapters/mongoid/ransack/visitor.rb index a6a507c..6bc4e59 100644 --- a/lib/ransack/adapters/mongoid/ransack/visitor.rb +++ b/lib/ransack/adapters/mongoid/ransack/visitor.rb @@ -14,5 +14,13 @@ def quoted?(object) end end + def visit_Ransack_Nodes_Sort(object) + if object.valid? + object.context.object.options[:sort] = {"#{object.name}": object.dir} + else + scope_name = :"sort_by_#{object.name}_#{object.dir}" + scope_name if object.context.object.respond_to?(scope_name) + end + end end end