Ok, I’m pretty new to Rails and I’m building a bug tracker as my first
real project. I have a situation where a bug can have multiple comments.
Pretty simple. When I show the comments on the screen, I want to make
sure that they’re displayed in reverse order by date created. I have
used the following to change the order of @bug.comments:
class Bug < ActiveRecord::Base
belongs_to :priority
has_many :comments
validates_presence_of :description, :priority
def comments
Comment.find :all, :order => ‘created_at DESC’
end
end
It works like a charm. But, is there a better way to do this? Should I
be returning it as-is and reversing it in the view instead?