5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/models/concerns/sort_field.rb', line 5
def sort_field(prefix = '')
prefix = "#{prefix}_" unless prefix == ''
if RocketCMS.mongoid?
field "#{prefix}order".to_sym, type: Integer
alias_method "#{prefix}sort", "#{prefix}order"
scope "#{prefix}ordered".to_sym, -> { asc("#{prefix}order".to_sym) }
scope "#{prefix}sorted".to_sym, -> { asc("#{prefix}order".to_sym) }
end
if RocketCMS.active_record?
scope "#{prefix}ordered".to_sym, -> { order("#{prefix}order".to_sym => :asc) }
scope "#{prefix}sorted".to_sym, -> { order("#{prefix}order".to_sym => :asc) }
end
end
|