Skip to content

dlabare/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.

Installation

Add this line to your application's Gemfile:

gem 'sortable_columns'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sortable_columns

Usage

  1. Add the sortable order to your .find, or .paginate

    def index @blobs = Blob.all(:order => sortable_order(Blob)) end

  2. 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 %>
  3. Profit.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

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