chris / better_nested_set
- Source
- Commits
- Network (11)
- Issues (3)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
-
in rails 2.3.4, attributes_with_quotes accepts 3 optional arguments, and in bns, it only accepts 2. this cause save to crash with a wrong number of arguments error.
Comments
-
Hi, i'm using this plugin to manage a structure of categories (one single root with, at now, 12-15000 children). I've noticed that running a simple script which create categories one after one at the end i had all the structure corrupted (lft and rgt not correct). I run a renumber_full_tree and everything went right again.
Then i removed some (~2-3000) categories with another simple script using the destroy method and after some (100-200) i had again all the structure broken. Then i used the delete method and called at the end the renumber_full_tree again, and it went right.
I'm very worried about this because the categories will increase exponentially (like one root and 500'000, 1'000'000 or even more children), and having this trouble would make all the website broken.
Do you know what would it be the cause?Comments
I'm not sure. When you say the structure is corrupt, is it corrupt right after the deletes, as in, have you reloaded the objects you are examining for correctness? I haven't had any problems. I'm using a smaller number of items in our case, but I don't see how the number would matter at all (the code either works or it doesn't). Are any exceptions being thrown?
Hi chris, yes, i reloaded the objects after the deletes.
For example before the script, i had a structure like this:root a a1 a11 a12 a2 a3 b b1 b2 b3 etc..Then after the creation/destroy i had something like:
root a a1 a11 a12 a2 a3 b b1 b2 b3 etc..Having another group of categories under another child (luckily only for lft and rgt, parent_id wasn't touched so i was able to just run a renumber_full_tree)
The only problem i think about is that i got all the categories and then checked them, like
Category.all.each do |category|
category.destroy if category.something = '...' and category.all_children_count.zero? endWithout reloading all the categories, but i think that this isn't the problems as in the before_destroy of the plugin there is a:
self.reload # in case a concurrent move has altered the indexeswhich should be the solution for this cases
There weren't any exceptions or other outputs (just that for the destroy it took a while, as there are a lot of records to update, i think)
Usually it works correctly when you create/destroy a single object, but having a lot of them it collapsed, i don't know if maybe because the db (mysql), the plugin or what else :)
Just an OT question, do you think that there would be problems having a lot (1-2 millions) of children under a single root?
I mean, about updates and stuff like that... if you add/destroy a child at the start and it has to update thousands/millions of rows with the new lft/rgt i think it would take quite a lot (and we know that users hate to wait too long :( ) -
undefined method `siblings' for #<Class:0x50d6808>
2 comments Created 18 days ago by silmarilWhen I use the "roots" method it works. Records are created successfully and the tree works fine.
When trying to make use of "siblings" or any of the other methods, I get "undefined method" errors.
I'm using rails 2.3.3.
Comments





Thanks for the report. I haven't moved to Rails 2.3.4 yet, so haven't come across this. Not sure when I will - probably in the next couple weeks, but that's about as best a guess as I have right now. I suggest submitting a patch (or if you fork and fix, do a pull request).
Oops, re-opening, didn't mean to close.