# Awesome\_nested\_set is too paranoid for me :(

**URL:** <https://www.ruby-forum.com/t/awesome-nested-set-is-too-paranoid-for-me/168592>\
**Category:** Rails\
**Created:** [May 22, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/awesome-nested-set-is-too-paranoid-for-me/168592 "2009-05-22T18:42:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pietro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/47e85d/32.png) [@Pietro](https://www.ruby-forum.com/u/Pietro)\
**Post date:** [May 22, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/awesome-nested-set-is-too-paranoid-for-me/168592/1 "2009-05-22T18:42:45Z")

</div>

So awesome\_nested\_set protects its parent\_id attribute and even  
redefines the parent\_id= method. This is causing me difficulty.

My models have a uniqueness constraint on :name that is scoped by  
parent\_id. So I could create records with attrs

{ :name =\> foo, :parent\_id =\> nil }, and  
{ :name=\> foo, :parent\_id =\> 1 }

and they would be valid because they have different parents.

But, as best I can figure, to construct these with a\_n\_s I am supposed  
to create 2 records with

{ :name =\> foo }

and then hit one with move\_to\_root and the other with  
move\_node\_to\_child(1). But I cant do that because creating 2 records  
with the same name and parent\_id defaulting to nil fails validation.

I think I need to specify the parent at creation time. Is there any  
way I can get a\_n\_s to allow this??

Thanks/
