It is accomplished with calls ActiveRecord::Base.update_all, works fine on a whole subtree, and works by opening a gap for the destination, moving, and then closing the gap at the origin.
But I also did something else.The code used "foo( bar )" instead of "foo(bar)", it had the expected and actual results reversed in "assert_equal" in the tests, and a few other things. I took the liberty of fixing all of these while I was in there, anyway.
What's the policy on changing existing code to adhere to coding standards? Is that a good thing or a bad thing to do? Is it better to leave it, to keep the patch simpler?
I'm personally in favor of making code adhere to the standards, because it makes it easier to read, and because it increases the chance that people will adhere to them going forward. And looking at code that's half-adherent-half-not is even worse than pure non- adherence.
The code could use even more cleaning -- it feels a bit fragile, for example it does updates both on the object directly and using update_all, which means it has to reload the objects time and again. Also, if you manually change the parent_id of an object, the nested sets aren't updated, so you have to be fairly careful with how you interact with your objects.
My immediate needs are met with the current incarnation, though, so I'm looking to gauge interest and opinions before I progress further.
Patch attach! ...ed! /Lars
move_nodes_in_nested_set.diff
Description: Binary data
_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core