has_many, through with nested models?

I am not sure if this will work but could you provide a named_scope on
Forum that takes a user id as a parameter, :include topic, user,
comment and reply, and specify the condition that
forum.topic.user.id=user_id OR forum.topic.comment.user.id = user_id
OR forum.topic.reply.user.id=user_id.

I am not sure if the include user will include comment.user and
reply.user, I am working out of my comfort zone here. If there is not
a rails way to do it then you could always just write the above as SQL
though I always try and avoid this.

Colin

Thx, Colin. I didnt see your reply, but I got a very similar answer
today on StackOverflow:

http://stackoverflow.com/questions/2187430/how-to-define-a-named-scope-to-roll-up-a-has-many-with-nested-models/2187447#2187447

Basically, it looks like this:

class Forum < ActiveRecord::Base
  has_many :topics, :dependent => :destroy, :order => 'created_at
desc'
  named_scope :user_posted, lambda {|user|
    { :joins => "JOIN topics t ON t.forum_id = forums.id " +
        "JOIN comments c ON c.topic_id = t.id " +
        "JOIN replies r ON r.comment_id = c.id",
      :conditions => ["t.user_id = ? OR c.user_id = ? OR r.user_id
= ?",
        user, user, user],
      :group => "forums.id"
    }
  }
end