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
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---