Nested set - problems when creating child item


#1

Hi,

I’ve created a Model with Better Nested Set, but i’m having problems
to create child items

My workflow is:

  • In the (new) form, i pass the desired parent_id in a hidden field.
  • In the create action, i create the register and after saving it i
    use the move_to_child_of method.

Everything works! My only problem is that Rails warns that I can’t
mass asign the property “parent_id”

How can i avoid this warning? Below is my create 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” }