This is more a Ruby problem.
To sort an array (which is what I assume that @dates is) you need to use the
Array#sort method
<% @dates.sort{|a,b| a.date <=> b.date}.each do |date| %>
That will probably put them in ascending order, for descending order switch
the a and b round.
However. It would be better if the data in @dates was in the correct order
when it is collected by the controller. When you use Active Record to get
data from the database you can get it to sort the data for you with,
something like, :order => 'date'.
You'll have to look up the docs, I've not had my morning coffee yet
It is a better practice to get the data in the right order when you get it
from the database if you can, it's not always possible.
--
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.