Class: PoBox::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PoBox::ApplicationRecord
- Defined in:
- app/models/po_box/application_record.rb
Class Method Summary collapse
- .sort_by_params(column, direction) ⇒ Object
-
.sortable_columns ⇒ Object
Returns an array of sortable columns on the model Used with the Sortable controller concern.
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_columns ⇒ Object
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 |