Sha256: 5d29b1e975da02f4f502700ef80b531b647a87487b4db6fb548884e9879ffb1b

Contents?: true

Size: 294 Bytes

Versions: 5

Compression:

Stored size: 294 Bytes

Contents

module SortField
  extend ActiveSupport::Concern

  module ClassMethods
    def sort_field(prefix = '')
      prefix = "#{prefix}_" unless prefix == ''

      field "#{prefix}sort".to_sym, type: Integer
      scope "#{prefix}sorted".to_sym, -> { asc("#{prefix}sort".to_sym) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rocket_cms-0.4.2 app/models/concerns/sort_field.rb
rocket_cms-0.3.2 app/models/concerns/sort_field.rb
rocket_cms-0.2.12 app/models/concerns/sort_field.rb
rocket_cms-0.2.10 app/models/concerns/sort_field.rb
rocket_cms-0.1.13 app/models/concerns/sort_field.rb