]> source.dussan.org Git - redmine.git/commitdiff
move r12689 awesome_nested_set modification to config/initializers/10-patches.rb...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 27 Jan 2014 06:47:46 +0000 (06:47 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 27 Jan 2014 06:47:46 +0000 (06:47 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12733 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/10-patches.rb
lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb

index 0ddbcdd06cbc3787b49195e3dcbeb9895e6654a9..881206c9e8738af2c62a409e9f64d63d863c24fa 100644 (file)
@@ -203,6 +203,8 @@ module ActionController
   end
 end
 
+require 'awesome_nested_set/version'
+
 module CollectiveIdea
   module Acts
     module NestedSet
@@ -211,6 +213,23 @@ module CollectiveIdea
           new_record? || leaf_without_new_record?
         end
         alias_method_chain :leaf?, :new_record
+        # Reload is needed because children may have updated
+        # their parent (self) during deletion.
+        if ::AwesomeNestedSet::VERSION > "2.1.6"
+          module Prunable
+            def destroy_descendants_with_reload
+              destroy_descendants_without_reload
+              reload
+            end
+            alias_method_chain :destroy_descendants, :reload
+          end
+        else
+          def destroy_descendants_with_reload
+            destroy_descendants_without_reload
+            reload
+          end
+          alias_method_chain :destroy_descendants, :reload
+        end
       end
     end
   end
index 81ecbc6b3bcde3522407b041d02d3f5e50f7e351..c831c48fcd2d55871ba7e0765088b2cc61f28a74 100644 (file)
@@ -593,8 +593,6 @@ module CollectiveIdea #:nodoc:
               ["#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)", diff]
             )
 
-            # Reload is needed because children may have updated their parent (self) during deletion.
-            reload
             # Don't allow multiple calls to destroy to corrupt the set
             self.skip_before_destroy = true
           end