Sort by column headers in Rails 2.0

hello,

I’m attempting to implement the code created by Dave B. to sort by
column headers shown here:

http://www.koders.com/ruby/fidA98C27CE5EEE13550817B81CF0B07DAADAAA9B37.aspx?s=sort#L1

Well, i wouldn’t be writing here if it worked, so I’m wondering if
someone could tell me what i’m doing wrong. I keep getting the error,
“uninitialized class variable @@sort_keys in SortHelper”. Below is my
view code that is getting hung up and my controller code. Any advice
would help

Dave

View:

Controller:

class ToolsController < ApplicationController

helper :sort
include SortHelper

the following method should sort columns

def list # action
SortHelper.columns = %w[
title
status
priority
owner
eta
]
SortHelper.default_order = %w[title status priority owner eta]
@people = Person.find_all.sort do |a, b|
SortHelper.sort(a, b, @params)
end
end

<%= link_to_sort_by 'Title', 'title' %> Description <%= link_to_sort_by 'Status', 'status' %> <%= link_to_sort_by 'Priority', 'priority' %> <%= link_to_sort_by 'Owner', 'owner' %> <%= link_to_sort_by 'Eta', 'eta' %>

I can’t help with the sort helper, but I did just release a Rails
plugin gem to help with setting up sortable tables in Rails:
http://sortablecolumns.rubyforge.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs