forked from halfcat/sortable_columns
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
38 lines (25 loc) · 802 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SortableColumns
===============
A drop plugin for creating headers to easily sort a listing by any of it's columns.
Example
=======
./script/plugin install git://github.com/dlabare/sortable_columns.git
1) Add the sortable order to your .find, or .paginate
def index
@blobs = Blob.all(:order => sortable_order(Blob, :custom_keys => { 'association_object' => 'association_objects.name' ))
end
2) Add the header links when listing your blobs.
<table>
<tr>
<th><%= link_to 'Name', sort_params(Blob, :name) %></th>
<th><%= link_to 'Rank', sort_params(Blob, :rank) %></th>
</tr>
<% @blobs.each do |blob| %>
<tr>
<td><%= blob.name %></td>
<td><%= blob.rank %></td>
</tr>
<% end %>
</table>
3) Profit.
Copyright (c) 2009 Daniel LaBare, released under the MIT license