IMO you are on the right way. Pass a sort_by parameter to your index
action and use it as :order option for your News.find method..


lg // andreas

--
DynamicDudes

Lightweight Ruby on Rails application development
http://dynamicdudes.com
http://rubyphunk.com




On Mon, Oct 20, 2008 at 4:14 PM, bingo bob
<[EMAIL PROTECTED]> wrote:
>
> 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?
>
> Thanks
>
>
> bb
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to