Scott Seago
2009-May-22 16:37 UTC
[Ovirt-devel] [PATCH server] fix for BZ #477796: pool name uniqueness
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
Jason Guiditta
2009-May-28 15:47 UTC
[Ovirt-devel] [PATCH server] fix for BZ #477796: pool name uniqueness
ACK, I now get the expected 'name already taken' error. On Fri, May 22, 2009 at 12:37 PM, Scott Seago <sseago at redhat.com> wrote:> 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 > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-devel >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090528/f3589bc2/attachment.htm>
Reasonably Related Threads
- [PATCH server] fix for Bug 466731 - There is no title for the third column in User Access page and can't be sorted
- [PATCH server] don't add nil key to failures hash for PartialSuccessError handling.
- re-sending outstanding controller refactoring patches after rebase
- Rails - Mock going out of scope?
- [PATCH server] fixed UI update bug -- ignore task_types when it doesn't exist