Module: Acts::DataTable::SortableColumns::ActionController
- Defined in:
- lib/acts_as_data_table/sortable_columns/action_controller.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.clear_request_sort_columns! ⇒ Object
Deletes the current sort columns from the thread space.
-
.get_request_sort_columns ⇒ Array<String>
Retrieves the columns to order by for the current request from the thread space.
- .included(base) ⇒ Object
-
.set_request_sort_columns!(columns) ⇒ Object
Sets the columns to order by for the current request in the thread space.
Instance Method Summary collapse
-
#current_sortable_columns ⇒ Object
Returns the currently active sortable columns.
Class Method Details
.clear_request_sort_columns! ⇒ Object
Deletes the current sort columns from the thread space
105 106 107 |
# File 'lib/acts_as_data_table/sortable_columns/action_controller.rb', line 105 def self.clear_request_sort_columns! Thread.current[:sortable_columns] = nil end |
.get_request_sort_columns ⇒ Array<String>
Retrieves the columns to order by for the current request from the thread space. This is used in the model’s scope, so no string has to be supplied in the controller action manually.
88 89 90 |
# File 'lib/acts_as_data_table/sortable_columns/action_controller.rb', line 88 def self.get_request_sort_columns Thread.current[:sortable_columns] || [] end |
.included(base) ⇒ Object
5 6 7 |
# File 'lib/acts_as_data_table/sortable_columns/action_controller.rb', line 5 def self.included(base) base.extend(ClassMethods) end |
.set_request_sort_columns!(columns) ⇒ Object
Sets the columns to order by for the current request in the thread space
98 99 100 |
# File 'lib/acts_as_data_table/sortable_columns/action_controller.rb', line 98 def self.set_request_sort_columns!(columns) Thread.current[:sortable_columns] = columns end |
Instance Method Details
#current_sortable_columns ⇒ Object
Returns the currently active sortable columns. This function should only be used when the automatic scope with_sortable_columns
is not working due to a different execution time or thread, e.g. a background worker.
77 78 79 |
# File 'lib/acts_as_data_table/sortable_columns/action_controller.rb', line 77 def current_sortable_columns Acts::DataTable::SortableColumns::ActionController.get_request_sort_columns end |