Skip to content

Drop in support for one click sorting of your model's columns.

License

Notifications You must be signed in to change notification settings

polydectes/sortable_columns

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Drop in support for one click sorting of your model's columns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%