Ticket #25 (new enhancement)

Opened 2 years ago

Managing scope when working with multiple trees should be easier

Reported by: Krishna Assigned to: jcm
Priority: major Milestone:
Component: plugin Version:
Keywords: scope multiple trees Cc:

Description

We need some way in which the scope of an object gets set automatically based on the parent, to avoid cumbersome code like this:

def create_subproject
  @project = Project.new(params[:project])
  if @project.save
    if params[:parent_id].empty?
      # this project has no parent, so it is the root of a new tree
      @project.update_attribute("root_id", @project.id)
    else
      @parent = (params[:parent_id])
      @project.update_attribute("root_id", @parent.root_id)
      @project.move_to_child_of @parent
    end
    flash[:notice] = 'Project was successfully created.'
    redirect_to :action => 'list'
  else
    render :action => 'new'
  end
end

Personally, I have the ultimate goal of making it as easy and transparent to work with multiple trees as it is in acts_as_tree.