GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ryana/sortable_table: Sort HTML tables in a Rails app.

BranchesTags
Open more actions menu

Latest commit

 

History

28 Commits
28 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
rails
rails
 
 
test/rails_root
test/rails_root
 
 
MIT-LICENSE
MIT-LICENSE
 
 
README.textile
README.textile
 
 
Rakefile
Rakefile
 
 
VERSION.yml
VERSION.yml
 
 
init.rb
init.rb
 
 
notes.rb
notes.rb
 
 
sortable_table.gemspec
sortable_table.gemspec
 
 

Repository files navigation

Sortable Table

Sort HTML tables in a Rails app.

Install

script/plugin install git://github.com/dancroak/sortable_table.git

In test/test_helper.rb:

class Test::Unit::TestCase include SortableTable::Test::TestHelper end

In app/controllers/application_controller.rb:

class ApplicationController < ActionController::Base include SortableTable::App::Controllers::ApplicationController end

In app/helpers/application_helper.rb:

module ApplicationHelper include SortableTable::App::Helpers::ApplicationHelper end

Conventions

params[:sort] and params[:order]

Examples

Use the sortable_attributes macro to list the… sortable attributes.

Then, in your index action, pass the sort_order method to your usual
order parameter for will paginate or named scope call.

class UsersController < Admin::BaseController sortable_attributes :name, :email def index @users = User.paginate :page => params[:page], :order => sort_order end end

Time-saving Shoulda macros for your tests:

class UsersControllerTest < ActionController::TestCase context ‘GET to index with sort and order params’ do setup do 5.times do |each| Factory :user, :name => “name #{each}”, :email => “email#{each}@example.com” end end should_sort_by :name should_sort_by :email end end

And some sugar for your views:

%h1 Users %table %tr = sortable_table_header :name => ‘Name’, :sort => ‘name’ = sortable_table_header :name => ‘E-mail’, :sort => ‘email’ - @users.each do |each| %tr %td= each.name %td= each.email

Authors
-——

Dan Croak, Joe Ferris, and Boston.rb.

Copyright © 2008 Dan Croak, released under the MIT license

About

Sort HTML tables in a Rails app.

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.