Sha256: deebf7373b528252d18d12ddc750da2e0c4978e9d5e636d2345e641458f5c948
Contents?: true
Size: 693 Bytes
Versions: 21
Compression:
Stored size: 693 Bytes
Contents
module SortField extend ActiveSupport::Concern module ClassMethods 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 end end
Version data entries
21 entries across 21 versions & 1 rubygems