Forum: Ruby on Rails better nested set and parent_id

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
cassiozen (Guest)
on 2009-02-20 04:49
(Received via mailing list)
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?
cassiozen (Guest)
on 2009-02-20 14:43
(Received via mailing list)
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
This topic is locked and can not be replied to.