Jason Guiditta
2008-Oct-31 19:01 UTC
[Ovirt-devel] [PATCH server] BUGFIX: 500 error if no smart pools exist.
This was happening when you clicked any tab that contained a smart pool dropdown when no smart pools exist (like on new appliance install). smart_pools_for_user was failing when there was no :children element. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- src/app/models/smart_pool.rb | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/models/smart_pool.rb b/src/app/models/smart_pool.rb index 0ecbe05..ac6db5e 100644 --- a/src/app/models/smart_pool.rb +++ b/src/app/models/smart_pool.rb @@ -80,19 +80,21 @@ class SmartPool < Pool other_pools = [] nested_pools.each do |pool_element| pool = pool_element[:obj] - if pool.name == user - pool_element[:children].each do |child_element| - child_pool = child_element[:obj] - user_pools <<[child_pool.name, child_pool.id] - end - else - pool_element[:children].each do |child_element| - child_pool = child_element[:obj] - other_pools << [pool.name + " > " + child_pool.name, child_pool.id] + if pool.hasChildren + if pool.name == user + pool_element[:children].each do |child_element| + child_pool = child_element[:obj] + user_pools <<[child_pool.name, child_pool.id] + end + else + pool_element[:children].each do |child_element| + child_pool = child_element[:obj] + other_pools << [pool.name + " > " + child_pool.name, child_pool.id] + end end end end - user_pools[-1] << "break" + user_pools[-1] << "break" unless user_pools.empty? user_pools + other_pools end end -- 1.5.6.5