Module: Handles::SortableColumns
- Included in:
- ActionController::Base
- Defined in:
- lib/handles/sortable_columns.rb
Overview
Overview
A sortable columns feature for your controller and views.
Basic Usage
Activate the feature in your controller class:
class MyController < ApplicationController
handles_sortable_columns
...
In a view, mark up sortable columns by using the sortable_column
helper:
<%= sortable_column "Product" %>
<%= sortable_column "Price" % >
In controller action, fetch and use the order clause according to current state of sortable columns:
def index
order = sortable_column_order
@records = Article.order(order) # Rails 3.
@records = Article.all(:order => order) # Rails 2.
end
That’s it for basic usage. Production usage may require passing additional parameters to listed methods.
See also:
-
MetaClassMethods#handles_sortable_columns
-
InstanceMethods#sortable_column_order
Defined Under Namespace
Modules: InstanceMethods, MetaClassMethods Classes: Config
Class Method Summary collapse
-
.included(owner) ⇒ Object
:nodoc:.
Class Method Details
.included(owner) ⇒ Object
:nodoc:
33 34 35 |
# File 'lib/handles/sortable_columns.rb', line 33 def self.included(owner) #:nodoc: owner.extend MetaClassMethods end |