Form to sort an index in rails
- by shmichael
I'm a newcomer to Rails. I want to build a simple form that determines the sort order of a list.
I've implemented a form in the likes of -
<%= radio_button_tag :sort, "rating" %>
<%= label_tag :sort_rating, "order by rating" %>
<%= radio_button_tag :sort, "name" %>
<%= label_tag :sort_name, "order by name" %>
And now I am unsure how to implement the sort at the controller/model level. The aspects I am puzzled about are:
Where should the sort be performed
How could the sort parameter be persisted
How could the code be reused
Right now, I can't even get the selected sort method to remain selected after a submit.
I would most appreciate any guidance or reference to an example.