[Ovirt-devel] [PATCH server] fix for BZ #477796: pool name uniqueness

Scott Seago sseago at redhat.com
Fri May 22 16:37:25 UTC 2009


We already had the validation rule in place, but the way the betternestedset API sets the parent_id the rules were being bypassed.

Signed-off-by: Scott Seago <sseago at redhat.com>
---
 src/app/models/pool.rb |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 2979fcb..0a63723 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -65,6 +65,9 @@ class Pool < ActiveRecord::Base
     transaction do
       save!
       move_to_child_of(parent)
+      # second save! call is to trigger validation rules related to parent_id
+      # since this nested set API call bypasses the standard AR validation
+      save!
       parent.permissions.each do |permission|
         new_permission = Permission.new({:pool_id     => id,
                                          :uid         => permission.uid,
-- 
1.6.0.6




More information about the ovirt-devel mailing list