awesome_nested_set is used to store a hierarchical data structure in a relationship database. here is a terrific article on how we can store a tree structure in a database
http://www.sitepoint.com/hierarchical-data-database/
http://www.sitepoint.com/hierarchical-data-database-2/
awesome_nested_set also uses the same technique to store the tree structure in the database, and the tree should not have a cyclic relation !!
So make sure! there are no cyclic parent child relationships between nodes. awesome_nested_set to check if this move can create a cyclic relation, it will throw an exception "Impossible move, target node cannot be inside moved tree."
Example
Food |\ Fruit | |\Red | | \Cherry | |\Yellow | | \Banana |\Meat | |\Beef |\Pork
Now in this tree you can move the whole Fruit tree to the Meet node child element. But you cannot move the Fruit node to any Fruit child element because it will make a circular relation and it will be impossible to iterate through the tree.
Now back to your question
1-I do this so that the levels do not reach the depth You do not need to worry about tree levels, since awesome_nested_set can load whole subtrees in a single sql query, see Link 1, how it doses it
2 Any idea why I get this error "Impossible move .." Already explain why you get this error. You can prevent this error before moving any move check, if this action is valid with
move_possible?
Naveed
source share