# Better nested set and parent\_id

**URL:** <https://www.ruby-forum.com/t/better-nested-set-and-parent-id/160825>\
**Category:** Rails\
**Created:** [February 20, 2009, 3:49am UTC](https://www.ruby-forum.com/t/better-nested-set-and-parent-id/160825 "2009-02-20T03:49:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cassiozen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ed655f/32.png) [@cassiozen](https://www.ruby-forum.com/u/cassiozen)\
**Post date:** [February 20, 2009, 3:49am UTC](https://www.ruby-forum.com/t/better-nested-set-and-parent-id/160825/1 "2009-02-20T03:49:06Z")

</div>

Hello everybody

I have a model with better\_nested\_set. In my “new” form, i pass the  
desired parent\_id as a hidden field, and in the create action at the  
controller i save the new register and use move\_to\_child\_of Model  
(params[item][parent\_id])

Everything works, but at my log file it warns that i can’t mass asign  
the property “parent\_id”.

What can i do to avoid the warning?

---

<div class="post-metadata">

**Author:** ![cassiozen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ed655f/32.png) [@cassiozen](https://www.ruby-forum.com/u/cassiozen)\
**Post date:** [February 20, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/better-nested-set-and-parent-id/160825/2 "2009-02-20T13:43:24Z")

</div>

Here is my controller’s update action:

def create  
@invite = Invite.new(params[:invite])  
begin  
@parent\_invitee = Invite.find\_by\_id(params[:invite][:parent\_id])  
rescue Exception =\> exc  
logger.error(“Invalid parent\_id: #{exc.message}”)  
render :action =\> “new”  
end  
respond\_to do |format|  
if @invite.save  
@invite.move\_to\_child\_of(@parent\_invitee.id)  
flash[:notice] = ‘Invite was successfully created.’  
format.html { redirect\_to :action =\> “show”, :id =\>  
@invite.confirmation\_code }  
format.xml { render :xml =\> @invite, :status  
=\> :created, :location =\> @invite }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @invite.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end
