Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Allow sorting #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ransack/adapters/mongoid/ransack/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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