I have my own model:
class Comment < ActiveRecord::Base
belongs_to :parent, :class_name => 'Comment', :foreign_key => 'parent_id'
has_many :children, :class_name => 'Comment', :foreign_key => "parent_id"
end
Later, I want to make 1 sql call first to capture all the relevant comments and then display them recursively.
How do I recursively load a download?
comments = Comment.where(:post_id => @post_id).includes(:comments=> [:comments => [:comments ....
def show_comments(comment)
render comment
comment.children.each do |child|
show_comments(child)
end
end
source
share