Better nested set and parent_id


#1

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?


#2

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