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' %> |
---|