Hi,
I have solved the problem Bob Sidebotham and Pirmin Kalberer were looking
at a month ago (19 Jan 2005): the sorting of columns by clicking headers. I read
Bob''s post about halfway through the process, and it helped, and I like
my
solution, so I thought I''d share it. (What''s the current best
method of sharing
Rails plugins?)
Anyway, here''s a quick synopsis:
=== View
<tr>
<th><%= link_to_sort_by ''First Name'',
''name'' %></th>
<th><%= link_to_sort_by ''Surname'',
''family.name'' %></th>
<th><%= link_to_sort_by ''Email'',
''email'' %></th>
</tr>
=== Controller:
helper :sort
def list # action
SortHelper.columns = %w[
name
family.name
email
]
SortHelper.default_order = %w[family.name name]
@people = Person.find_all.sort do |a, b|
SortHelper.sort(a, b, @params)
end
end
And your @people are sorted!
Please help yourself to my code here:
http://www.dave.burt.id.au/ruby/sort_helper.rb
Cheers,
Dave