Hello, I’m currently using the gem ‘nested_set’ for comment threading.
What I want to do is prevent the comment level from going more than 2 levels deep. What I tired doing was something like this:
class Comment < ActiveRecord::Base
We don’t want comments to go more than 2 levels deep. That’s overkill
if self.level > 2
self.level = 2
But it looks like you cant set a level only obtain an objects level. With the goal being to enforce a MAX of 2 levels deep for comment threading. Can anyone suggest a way to enforce that from happening?
The use case being:
Comment Main (level 0)
Comment Reply (level 1)
Comment Reply about XXXX (level 2)
When a user replies to the last one (about XXXX) I don’t want the comment to be set to a level of 3, I want to cap that at 2.