Chris Birkinshaw
2006-Apr-28 11:30 UTC
[Rails] Add extra data to objects in an instance variable?
I am building an issue log with models: issues (belongs_to :user, has_many :comments) comments (belongs_to :issues, belongs_to :user) users (has_many :comments, has_many :issues) In the list view for the issues I wanted to print the time it was last updated. This should come from the most recent comment added, or if there are no comments added we fall back to the creation time of the issue: <% @last_update = Comment.find(:first, :order => ''added desc'', :conditions => ["issue_id = ?", issue.id]) %> <% if @last_update %> <%= @last_update.added %> <% else %> <%= issue.added %> <% end %> This all works fine, however I now want to order by this data in the paginator. I assume that I need to run though a loop adding some data to all the objects in the @issues = Issue.find_all instance variable in the list part of the issues controller, but how do I do this? Best regards, Chris -- Posted via http://www.ruby-forum.com/.