search for: ensure_max_nestedset_level

Displaying 2 results from an estimated 2 matches for "ensure_max_nestedset_level".

2011 Mar 08
2
Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.
Hello, I''m using the Awesome Nested Set plugin: https://github.com/collectiveidea/awesome_nested_set And in my model I do the following: acts_as_nested_set after_save :ensure_max_nestedset_level private def ensure_max_nestedset_level if self.level > 2 self.move_to_child_of(parent.parent) end end I do this to keep the levels from getting to deep. Any idea why I''m getting this "Impossible move, target node cannot be inside moved tree.&quot...
2011 Feb 18
0
Acts as nested - Enforcing a Max Level
...o, 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 .... before_save :ensure_max_nestedset_level private # We don''t want comments to go more than 2 levels deep. That''s overkill def ensure_max_nestedset_level if self.level > 2 self.level = 2 end end end But it looks like you cant set a level only...