Class: PoBox::ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/po_box/application_record.rb

Direct Known Subclasses

Email, Inbox

Class Method Summary collapse

Class Method Details

.sort_by_params(column, direction) ⇒ Object



5
6
7
8
# File 'app/models/po_box/application_record.rb', line 5

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

.sortable_columnsObject

Returns an array of sortable columns on the model Used with the Sortable controller concern

Override this method to add/remove sortable columns



14
15
16
# File 'app/models/po_box/application_record.rb', line 14

def self.sortable_columns
  @sortable_columns ||= columns.map(&:name)
end