I’m building an application that lists events (music gigs) along with
the corresponding venues and towns where they are happening. I followed
the tutorial at http://dev.nozav.org/rails_ajax_table.html and can get
the list to sort by all columns except for by town, which is a parent of
venues, which in turn is a parent of gigs.
The relevant tables are set up as follows:
The gigs_controller.rb is then set up as follows
gigs_per_page = 20
sort = case @params['sort'] when "artist" then "artists.artist_name" when "venue" then "venues.venue_name"
broken when “town” then “venues.towns.town_name”
when "date" then "date_time" when "artist_reverse" then "artists.artist_name DESC" when "venue_reverse" then "venues.venue_name DESC"
broken when “town_reverse” then “venues.towns.town_name DESC”
when "date_reverse" then "date_time DESC" end @gigs_pages, @gigs = paginate :gigs, :order => sort, :conditions => "date_time >= now()", :per_page => gigs_per_page, :include => [:artist, :venue]
So, what I want to do is sort the list according to the name of the town
in the same way as the other columns - any suggestions?