Hi Krishna,<br><br>I have no move code (moving is not allowed! :D), my delete code is fairly straightforward:<br>&nbsp; def destroy<br>&nbsp;&nbsp;&nbsp; m = Message.find(params[:id])<br><br>&nbsp;&nbsp;&nbsp; #security check to make sure they can delete snipped
<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 
m.destroy<br>&nbsp;&nbsp;&nbsp; redirect_back_or_default :controller =&gt; :message_boards, :action =&gt; :show, :id =&gt; @current_message_board<br>&nbsp; end<br><br>All tables are innodb_tables:<br>SHOW CREATE TABLE messages;<br>CREATE TABLE `messages` (
<br>...<br>) ENGINE=InnoDB <span id="e_11465b10e45a442f_1"><br><br>--<br>Matt<br></span><br><div><span class="gmail_quote">On 8/14/07, <b class="gmail_sendername">Krishna Dole</b> &lt;<a href="mailto:dontfall@gmail.com">
dontfall@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Matt,<br><br>Is this the only code you have that alters the tree? Any delete/move
<br>code? Also, are you using a transactional storage engine? (basically<br>anything other than MyISAM, I think).<br><br>I presume the message_board_id is being set from params[:message].<br><br>Krishna<br><br>On 8/14/07, Matt Rogish &lt;
<a href="mailto:rogishmn@muohio.edu">rogishmn@muohio.edu</a>&gt; wrote:<br>&gt; I&#39;m not writing any SQL, I&#39;m using built-in better-nested-set functions.<br>&gt;<br>&gt; Here&#39;s my save:<br>&gt;&nbsp;&nbsp; def create<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; @message = Message.new(params[:message])<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if @message.save<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flash[:notice] = &#39;Message was successfully created.&#39;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if params[:message][:parent_id]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @
message.move_to_child_of( Message.find params[:message][:parent_id]<br>&gt; )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @message.save<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; end<br>&gt;&nbsp;&nbsp; end<br>&gt;<br>&gt; --<br>&gt; Matt<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 8/14/07, Jeremy Nicoll &lt;
<a href="mailto:jnicoll@goldnoteexpress.com">jnicoll@goldnoteexpress.com</a> &gt; wrote:<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; I think it would be best if you could post your SQL that is messed up<br>&gt; as well as the code you are using to save your nodes.&nbsp;&nbsp;Unfortunately we
<br>&gt; can&#39;t tell you what is wrong until we actually see the logic behind what you<br>&gt; are doing.<br>&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; Jeremy Nicoll<br>&gt; &gt;<br>&gt; &gt; Matt Rogish wrote:<br>&gt; &gt;
<br>&gt; &gt; How can I repair my tree?<br>&gt; &gt;<br>&gt; &gt; I have a message board system in which the messages are grouped by<br>&gt; &quot;message_board_id&quot;, thus my model is:<br>&gt; &gt; acts_as_nested_set :scope =&gt; :message_board_id
<br>&gt; &gt;<br>&gt; &gt; Somehow the tree is messed up, inasmuch as some roots (parent_id == null)<br>&gt; are being set to the children of some other message, so I cannot<br>&gt; successfully repair it. I&#39;m not sure if I&#39;m performing incorrect operations
<br>&gt; or what, but somehow I need to repair my tree where message_board_id = 34<br>&gt; (or whatever it is).<br>&gt; &gt;<br>&gt; &gt; It seems as if renumber_full_tree tries to find the virtual root for a<br>&gt; given node, but since the root itself is a CHILD of another node, the whole
<br>&gt; thing fails. My layman&#39;s guess is that the &quot;root&quot; condition is wrong, since<br>&gt; it&#39;s doing WHERE parent_id IS NULL ... AND lft BETWEEN .. AND ..<br>&gt; &gt;<br>&gt; &gt; Well, if the root is incorrectly between something, then the lft would
<br>&gt; fail, no? Maybe I&#39;m misreading that. Help!!<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; Matt<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On 8/14/07, Matt Rogish &lt;<a href="mailto:rogishmn@muohio.edu">
rogishmn@muohio.edu</a>&gt; wrote:<br>&gt; &gt; &gt; Under heavy load we are getting significantly screwed up data. I have to<br>&gt; run renumber_full_tree in script/console production order to repair the<br>&gt; thing.<br>
&gt; &gt; &gt;<br>&gt; &gt; &gt; Obviously this is a bad thing, but I don&#39;t even know where to start to<br>&gt; fix it. Any ideas?<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Thanks,<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; --<br>
&gt; &gt; &gt; Matt<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt; ________________________________<br>&gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Betternestedset-talk mailing list<br>&gt; &gt; 
<a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk
</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Betternestedset-talk mailing list<br>&gt; &gt; <a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org
</a><br>&gt; &gt;<br>&gt; <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________
<br>&gt; Betternestedset-talk mailing list<br>&gt; <a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>&gt; <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk
</a><br>&gt;<br>&gt;<br>_______________________________________________<br>Betternestedset-talk mailing list<br><a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">
http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br></blockquote></div><br>