Another active record question

Here is a model i am using

class Post < ActiveRecord::Base
has_many :posts, :class_name => “Post”, :foreign_key => “message_id”
has_one :last_reply, :class_name => “Post”, :foreign_key =>
“message_id”, :order => “created_at DESC”
belongs_to :area
belongs_to :user

end

what i need to do is select a number of posts and sort them by the date
of the “last_reply”. Something like this would be ideal but it does not
work.

class Area < ActiveRecord::Base
has_many :topics, :class_name => “Post”, :foreign_key => “area_id”,
:order => “last_reply.created_at DESC”, :conditions => “message_id = -1”
end

is there a way i can tell another model to sort by “last_reply”?

thanks for your time reading this

Anybody with any insight on this one? I’ve just come across a similar
issue.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs