Dubocit wrote: > 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.
This isn't true. Rails has no default for sorting result sets. Rails just includes them in the order the query provides them. > How can I go about displaying this table by dates and what's the best way to > do it? Ask the database to put them in the order you want inside your controller action. It's should the controller's responsibility to fetch and organize the data to be presented not the view's. def index @dates = DateModel.find(:all, :order => "date") end P.S. I hope did didn't name your ActiveRecord model "Date" that might cause you problems in the future. P.P.S. I'd also recommend not naming a database column "date" either. You may run into naming conflicts and other issues as well. Rails has a convention for naming date and time related fields (i.e. created_at, updated_on). I'd recommend following that convention for your own date fields. Use *_on for date fields and *_at for datetime fields in order to avoid any possible naming conflicts. -- 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.

