Sorting an array in a partial file


#1

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.


#2

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.


#3

Nevermind. I figured it out I just needed to add (:all, :order =>
‘time’) to the render.


#4

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: