module Acts::DataTable::SortableColumns::ActionController
Public Class Methods
clear_request_sort_columns!()
click to toggle source
Deletes the current sort columns from the thread space
# 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()
click to toggle source
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.
@return [Array<String>] the columns and their sorting directions in the format
[["col1", "dir1"], ["col2", "dir2"], ...]
# 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)
click to toggle source
# 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)
click to toggle source
Sets the columns to order by for the current request in the thread space
@param [Array<String>] columns
# 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
Public Instance Methods
current_sortable_columns()
click to toggle source
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.
# 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