103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/scoped_search.rb', line 103
def scoped_order(*columns_names)
if defined?(Mongoid) && self.include?(Mongoid::Document)
columns_names.each do |column_name|
scope :"ascend_by_#{column_name}", order_by([column_name.to_sym, :asc])
scope :"descend_by_#{column_name}", order_by([column_name.to_sym, :desc])
end
else
columns_names.each do |column_name|
scope :"ascend_by_#{column_name}", order("#{column_name} asc")
scope :"descend_by_#{column_name}", order("#{column_name} desc")
end
end
end
|