A drop plugin for creating headers to easily sort a listing by any of it's columns.
Add this line to your application's Gemfile:
gem 'sortable_columns'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sortable_columns
-
Add the sortable order to your .find, or .paginate
def index @blobs = Blob.all(:order => sortable_order(Blob)) end
-
Add the header links when listing your blobs.
<% @blobs.each do |blob| %>
<% end %><%= link_to 'Name', sort_params(Blob, :name) %> <%= link_to 'Rank', sort_params(Blob, :rank) %> <%= blob.name %> <%= blob.rank %> -
Profit.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2009 Daniel LaBare, released under the MIT license