Created
June 10, 2014 11:04
-
-
Save almaron/5739bfb6acc9a05b79a6 to your computer and use it in GitHub Desktop.
Can anyone help me simplify this?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#forum.rb | |
def get_all_posts | |
forums = self.subtree_ids | |
topics = Topic.where(forum_id: forums).collect(&:id) | |
posts = Post.where(topic_id: topics) | |
end | |
# Forum has_many :topics and has_ancestry | |
# Topic has_many :posts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment