I'm not writing any SQL, I'm using built-in better-nested-set functions.<br><br>Here's my save:<br> def create<br> @message = Message.new(params[:message])<br><br> if @message.save<br> flash[:notice] = 'Message was successfully created.'
<br> <br> if params[:message][:parent_id] <br> @message.move_to_child_of( Message.find params[:message][:parent_id] )<br> @message.save<br> end<br> end<br> end<br><br>--<br>Matt<br>
<br>
<div><span class="gmail_quote">On 8/14/07, <b class="gmail_sendername">Jeremy Nicoll</b> <<a href="mailto:jnicoll@goldnoteexpress.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jnicoll@goldnoteexpress.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
I think it would be best if you could post your SQL that is messed
up as well as the code you are using to save your nodes. Unfortunately
we can't tell you what is wrong until we actually see the logic behind
what you are doing.<br>
<br>
--<br>
Jeremy Nicoll<br>
<br>
Matt Rogish wrote:
<blockquote type="cite"><div><span>How can I repair my tree?<br>
<br>
I have a message board system in which the messages are grouped by
"message_board_id", thus my model is:<br>
acts_as_nested_set :scope => :message_board_id <br>
<br>
Somehow the tree is messed up, inasmuch as some roots (parent_id ==
null) are being set to the children of some other message, so I cannot
successfully repair it. I'm not sure if I'm performing incorrect
operations or what, but somehow I need to repair my tree where
message_board_id = 34 (or whatever it is).
<br>
<br>
It seems as if renumber_full_tree tries to find the virtual root for a
given node, but since the root itself is a CHILD of another node, the
whole thing fails. My layman's guess is that the "root" condition is
wrong, since it's doing WHERE parent_id IS NULL ... AND lft BETWEEN ..
AND ..
<br>
<br>
Well, if the root is incorrectly between something, then the lft would
fail, no? Maybe I'm misreading that. Help!!<br>
<br>
Thanks,<br>
<br>
--<br>
Matt<br>
<br>
<div><span class="gmail_quote">On 8/14/07, <b class="gmail_sendername">
Matt Rogish</b> <<a href="mailto:rogishmn@muohio.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rogishmn@muohio.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Under
heavy load we are getting significantly screwed up data. I have to run
renumber_full_tree in script/console production order to repair the
thing.<br>
<br>
Obviously this is a bad thing, but I don't even know where to start to
fix it. Any ideas?
<br>
<br>
Thanks,<br>
<br>
--<br>
<span>Matt<br>
</span></blockquote>
</div>
<br>
</span></div><pre><hr size="4" width="90%">
_______________________________________________<br>Betternestedset-talk mailing list<br><a href="mailto:Betternestedset-talk@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Betternestedset-talk@rubyforge.org
<br></a>
<a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a>
</pre>
</blockquote>
</div>
<br>_______________________________________________<br>Betternestedset-talk mailing list<br><a href="mailto:Betternestedset-talk@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Betternestedset-talk@rubyforge.org
</a><br><a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br><br></blockquote>
</div><br>