-
Notifications
You must be signed in to change notification settings - Fork 241
.hash_tree returning NoMethodError: undefined method `[]=' for nil:NilClass #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you have a db backup from when it was broken? If you can share the result of: SELECT id, parent_id, name
FROM taxonomies We can shove the data into a spec and try to reproduce the issue. |
ping |
Hey @mceachen, pong Sorry, it has been a busy week. I destroyed all records and started from scratch. I got no errors so far. I will try reproducing the issue again in the next couple of days. Thanks. |
OK, then, I don't think we can move forward here. Feel free to reopen this issue or open a new one if you find this happen again. With a data dump we'll be able to quickly get the to bottom of whatever happened. If you've got a multithreaded app that's creating lots of hierarchies, I'm working on integrating monogamy with closure_tree to make sure the transaction boundaries are correct. You may have been bitten by duplicative rows, but I can't even guess without your data when it was broken. |
I looked at this more in the light of #146, and the issue here is that you are incanting hash_tree against a relation object from a non-closure-tree model. ActiveRecord added If you don't mind multiple selects: Company.first.taxonomies.map(&:hash_tree).reduce(&:merge) |
👍 2 years later, but still relevant 😊 |
did you try the .map.reduce? |
@mceachen |
I have a weird problem here. I added some nodes and suddenly I can't use
Taxonomy.hash_tree
anymore.I thought, "ok, given I just started out, I'll just delete everything and start over", but then what if this issue happens when I go to production?
In fact, after starting over and recreating the nodes, I haven't got the error so far.
Do you have any idea what this could be?
Thanks!
Data
Here, everything's ok.
Problematic hash_tree
Here, the error.
The text was updated successfully, but these errors were encountered: