[Betternestedset-talk] Application suggestions
Nick Pavlica
linicks at gmail.com
Fri Dec 22 20:09:39 EST 2006
> Are your root trees ordered or not ?
I don't think that they are ordered. Essentially, I have a chain of
sub_projects where I can have one or more sub projects at the same
level with an unlimited depth, but the aren't specifically ordered.
If they aren't, use the :scope to
> store your 500,000 trees in the same table, without interaction between
> each of them. This should be very efficient.
Not quite sure what you mean here? But are you saying something like
:scope => parent_id ?
> > The main portion that I can't
> > seem to get past is when I try to make the subproject a child of
> > what should be it's parent (move_to_child_of) after the save.
> >
> > @project.move_to_child_of ????
> >
> > Can you point me in the right direction, it would be much appreciated.
>
> Pass an id or an object of the new parent.
I'm able to assign a child when I'm at the console, as described on
the Wiki. I can also do it manually in my create subproject_method:
@project.move_to_child_of 1. But when I try to assign a variable in my
create_subproject method from the request parameters, I get a variety
of errors. I'm not sure where I'm dropping the ball yet :)
Here is my current create method
def create_subproject
@project = Project.new(params[:project])
@parent = (params[:parent_id])
#@parent = @project.parent_id
if @project.save
@project.move_to_child_of @parent
flash[:notice] = 'Project was successfully created.'
redirect_to :action => 'list'
else
render :action => 'new'
end
end
I get this error : Couldn't find Project without an ID
of course "parent_id"=>"1" is in the request parameters list in the
debug message.
I tried passing the value with the submit button on the form:
<%= submit_tag "Create", :project_id => @parent.id; %>
Where parent.id is set with the new method. This was how I was
inserting the parent ID when using acts_as_tree.
Thanks !
--Nick
More information about the Betternestedset-talk
mailing list