Commit 19f4ca26af1ee0d42c5289935e0a5103535ecc92
1 parent
31686d8c
Exists in
master
and in
29 other branches
ActionItem466: break the loop if no ids remain
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2062 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
lib/acts_as_filesystem.rb
@@ -165,6 +165,7 @@ module ActsAsFileSystem | @@ -165,6 +165,7 @@ module ActsAsFileSystem | ||
165 | while !current_level.empty? | 165 | while !current_level.empty? |
166 | result += current_level | 166 | result += current_level |
167 | ids = current_level.select {|item| item.children_count > 0}.map(&:id) | 167 | ids = current_level.select {|item| item.children_count > 0}.map(&:id) |
168 | + break if ids.empty? | ||
168 | current_level = self.class.find(:all, :conditions => { :parent_id => ids}) | 169 | current_level = self.class.find(:all, :conditions => { :parent_id => ids}) |
169 | end | 170 | end |
170 | block ||= (lambda { |x| x }) | 171 | block ||= (lambda { |x| x }) |