phoet
's answer intrigued me (I +1'd), so here's my refactor / expansion on what he suggested:
You'd look in the Comment
model to pull out the relevant comments. To do this, you need to firstly know the board & the pictures associated with it. Phoet uses the self.pictures
object for this:
#app/models/comment.rb
Class Board < ActiveRecord::Base
def all_comments
ids = self.id + self.pictures.map(&:id)
Comment.find(ids)
end
end
This will find the ids in the comment
model, returning the data as a collection. If you wanted a true representation of the comments (hierarchical), you'd have to use some sort of ancestry
/ inheritance
structure I think