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
deep. What I tired doing was something like this:
class Comment < ActiveRecord::Base .... before_save :ensure_max_nestedset_level private # We don't want comments to go more than 2 levels deep. That's
if self.level > 2
self.level = 2
But it looks like you cant set a level only obtain an objects level.
the goal being to enforce a MAX of 2 levels deep for comment threading.
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
be set to a level of 3, I want to cap that at 2.