Rails 3 - Recursive Relationship - Comments
-
12-11-2019 - |
Question
I'm trying to create a recursive relationship in rails so that comments can have replies (using the same model comment.rb). So basically, a comment has many comments(as replies) and a comment can belong to only one comment.
I have the fk in my migration, but was wondering what needs to be on my comment.rb model.
Is this the proper way?
has_many :comments, :as => :reply
belongs_to :comment
Sorry, just want to make sure I'm doing this the correct way.
Thank you
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow