Forum: Ruby on Rails Sorting an array in a partial file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aaron D. (Guest)
on 2009-06-09 07:02
I have a controller to sort by time...

 def index
    @shows = Show.all(:all, :order => 'time')

    respond_to do |format|
      format.html
      format.xml  { render :xml => @shows }
    end
  end

...which works fine when you view the 'shows' index.html.erb.

But I made a partial called _show_list.html.erb (which is 'shows'
index.html.erb) but it doesn't sort the listings by time.
Aaron D. (Guest)
on 2009-06-09 07:05
> But I made a partial called _show_list.html.erb (which is 'shows'
> index.html.erb) but it doesn't sort the listings by time.

BTW the partial is located in a different 'veiw' as its supposed to.
Aaron D. (Guest)
on 2009-06-09 11:25
Nevermind. I figured it out I just needed to add (:all, :order =>
'time') to the render.
Colin L. (Guest)
on 2009-06-09 11:43
(Received via mailing list)
Have a look at named_scope and default_scope. These may save you
sprinkling :order specs around the place.
Colin

2009/6/9 Aaron D. <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.