@@ -538,15 +538,18 module CollectiveIdea #:nodoc: | |||||
538 | end |
|
538 | end | |
539 | end |
|
539 | end | |
540 |
|
540 | |||
541 | # on creation, set automatically lft and rgt to the end of the tree |
|
541 | def right_most_bound | |
542 | def set_default_left_and_right |
|
542 | right_most_node = | |
543 | highest_right_row = |
|
|||
544 | self.class.base_class.unscoped. |
|
543 | self.class.base_class.unscoped. | |
545 | order("#{quoted_right_column_full_name} desc").limit(1).lock(true).first |
|
544 | order("#{quoted_right_column_full_name} desc").limit(1).lock(true).first | |
546 |
|
|
545 | right_most_node ? right_most_node[right_column_name] : 0 | |
|
546 | end | |||
|
547 | ||||
|
548 | # on creation, set automatically lft and rgt to the end of the tree | |||
|
549 | def set_default_left_and_right | |||
547 | # adds the new node to the right of all existing nodes |
|
550 | # adds the new node to the right of all existing nodes | |
548 |
self[left_column_name] = |
|
551 | self[left_column_name] = right_most_bound + 1 | |
549 |
self[right_column_name] = |
|
552 | self[right_column_name] = right_most_bound + 2 | |
550 | end |
|
553 | end | |
551 |
|
554 | |||
552 | def in_tenacious_transaction(&block) |
|
555 | def in_tenacious_transaction(&block) |
General Comments 0
You need to be logged in to leave comments.
Login now