I'm programming a section of my application that will store and list
stories. These stories should be sorted by three factors: genre,
order_by (such as time posted), and sort (ascending or descending). I
want to give my users the ability to easily sort through the list of
To achieve this, I've setup a named route:
map.sort_by 'stories/sort_by/:genre/:order_by/:sort', :controller =>
"stories", :action => "index" (Both :order_by and :sort may be left
I'm stuck at the point of actually sorting and returning the results
(the controller logic). I've done some research, though am still quite
a newbie on rails. >< In your opinion, what would be the best way to
sort the stories based off of what is, and is not supplied to the
controller? For example, if only params(:genre) is supplied, I want
the list of stories to only display the specified genre. However, if
params(:order_by) is also supplied, the list would be of one genre and
listed, ASC or DESC by whatever :order_by is targeting.
Thanks in advance for you help!