Let\'s say I have a comment model:
class Comment < ActiveRecord::Base
has_many :replies, class: \"Comment\", foreign_key: \"reply_id\"
end
It seems like what you have is one short step away from what you want. You just need to use recursion to call the same code for each reply as you're calling for the original comments. E.g.
<%= render partial: "comment", collection: @comments %>
NB: this isn't the most efficient way of doing things. Each time you call comment.replies active record will run another database query. There's definitely room for improvement but that's the basic idea anyway.
<%= comment.content %>
<%= render partial: "comment", collection: comment.replies %>