The library completely redesigned, tons of refactorings applied.
- Movement methods now use
ActiveRecord::Base#saveso all user validations and callbacks are invoked now. parent_idandpositionattributes are no longer protected by default. It's up to developer to make themattr_protectednow.
- Reduced amount of UPDATE SQL-queries during movements and reorders.
- Added collection iterators:
each_with_levelwhich yields each node of collection with its level.each_without_orphanswhich yields only that nodes which are not orphaned (i.e. that nodes which don't have corresponding parent within iterated collection).arrangewhich constructs hash of hashes where each key is node and value is its hash of its children.
- Added ability to explicitly set left/right sibling for node via
#left_sibling=and#right_sibling=methods (#30). .leavesscope now works even with models that don't havecounter_cachecolumn (#29).- Added method instance method
#move_to_child_with_positionwhich is similar to#move_to_child_with_indexbut is more human readable. - Full support for
before_add,after_add,before_removeandafter_removecallbacks (#25). - Descendants now can be arranged into hash with
#arrangemethod (#22). - Flexible control over tree traversals via blocks passed to
#descendantsand#ancestors(#21).
- Deprecated methods:
#insert_at. It is recommended to use#move_to_child_with_positioninstead.#branch? is deprecated in favour of#has_children?`.#child?is deprecated in favour of#has_parent?.#move_possible?is deprecated in favour of built-in and user defined validations.
Bug fixes:
- Fixed several issues that broke tree integrity.
- Fixed bug when two root nodes could be created with same position (#24).
- Fixed support of STI and basic inheritance.
- Fixed bug when user validations and callbacks weren't invoked on movements
via
move_to_*methods (#23).