Module: SortOrder

Included in:
PatientsController, TestPlansController, XdsUtilityController
Defined in:
lib/sort_order.rb

Overview

Include this module in controllers that need to handle sorting.

The sort specifier should be set using the :sort parameter. After the first use, the sort will be saved in the session for the current controller and action. When sort_order is called by the same controller and action in the same session, the results will include the previously specified sort order.

To use this module:

require 'sort_order'
class SomeController < Application
  include SortOrder
  self.valid_sort_fields = %w[ field1 field2 ] # optional

  def action
    render :text => "requested sort is #{sort_order}"
  end
end

Then, in the helper:

require 'sort_order'
module SomeHelper
  include SortOrderHelper
end

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary (collapse)

Class Method Details

+ (Object) included(klass)



28
29
30
31
32
33
34
35
# File 'lib/sort_order.rb', line 28

def self.included(klass)
  klass.class_eval do
    hide_action :sort_order
    hide_action :sort_spec
    include InstanceMethods
    extend ClassMethods
  end
end