I'm a newbie and was curious about displaying scaffold views ascending
or descending by date. Here's what my current view looks like. The
first column is the one I'd like to sort by so that the user can see
each date in order as the event date is approaching. My controller is
just the generated scaffold controller. I know that the default for
Rails is to display each record by when it was created. How can I go
about displaying this table by dates and what's the best way to do it?
Much thanks!

<h1>Listing Dates</h1>

<table>
  <tr>
    <th>Date</th>
    <th>Address1</th>
    <th>Address2</th>
    <th>City</th>
    <th>State</th>
  </tr>

<% @dates.each do |date| %>
  <tr>
    <td><%=h date.date %></td>
    <td><%=h date.address1 %></td>
    <td><%=h date.address2 %></td>
    <td><%=h date.city %></td>
    <td><%=h date.state %></td>
    <td><%= link_to 'Show', date %></td>
    <td><%= link_to 'Edit', edit_date_path(date) %></td>
    <td><%= link_to 'Destroy', date, :confirm => 'Are you
sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

-- 
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