I've got a puzzle question.
I've got a load of news_items that I find and sort by date in my
controller and then display in the view. Works just fine. I do this in
the index action.
It appears as tabular information, with column headings. As I say by
default I'm sorting by date.
What I'd like to do is after the list is rendered in the view, I'd like
to offer the user the ability to click on a different column heading to
sort by that column.
e.g. allow the user to sort by news_item.stock.sector
What I think I need is a link_to helper at the top for each column
heading to pass something back to the index action of the controller so
that I can repopulate the @news_items with a newly sorted list (as the
user clicks different column headings).
Am I on the right lines?
Can anyone help me do this?