Sha256: 2f21d700c1a6fda1cd6a86e876d130cfa3687b01f9c2c45257e9dc7645f293cd

Contents?: true

Size: 533 Bytes

Versions: 1

Compression:

Stored size: 533 Bytes

Contents

module PoBox
  class ApplicationRecord < ::ActiveRecord::Base
    self.abstract_class = true

    def self.sort_by_params(column, direction)
      sortable_column = column.presence_in(sortable_columns) || "created_at"
      order(sortable_column => direction)
    end

    # Returns an array of sortable columns on the model
    # Used with the Sortable controller concern
    #
    # Override this method to add/remove sortable columns
    def self.sortable_columns
      @sortable_columns ||= columns.map(&:name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
po_box-0.1.2 app/models/po_box/application_record.rb