Path: | sort_helper.rb |
Last Update: | Thu Feb 17 17:31:00 AUS Eastern Daylight Time 2005 |
Author: Dave Burt dave@burt.id.au
Version: 17 Feb 2005
Makes column headings users can click to define how the table is sorted.
<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>
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