Comments (7)
Thanks @diesl - can you please debug this a little on your local?
If you use bundle open awesome_nested_set
to open the gem in your editor, and put debugging statements (like require 'pry';binding.pry
or puts
) inside the method compute_level
then we can maybe see what the code is thinking about your table.
The relevant method is here
awesome_nested_set/lib/awesome_nested_set/model/relatable.rb
Lines 98 to 102 in 36ec2b0
from awesome_nested_set.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from awesome_nested_set.
Not stale, I still need to debug
from awesome_nested_set.
This is still valid. We ended up doing Category.all.each do |c| c.save;end;0
after rebuild in order to recall the depth.
from awesome_nested_set.
@parndt Finally I had some time for debugging.
I added a puts
statement at the beginning of def compute_level
. I did not get any output during Model.rebuild!
and after checking the gem code, indeed I do not see any code triggering the computation of the depth during the rebuild:
awesome_nested_set/lib/awesome_nested_set/tree.rb
Lines 18 to 28 in 36ec2b0
I would expect that depth
is set during rebuild. Do I have some misconception here?
Seems like you already discovered this behavior many years ago:
Yes, I've been noticing this too.. It seems the depth only gets built when you run save or move_to commands.
Originally posted by @parndt in #116 (comment)
from awesome_nested_set.
@diesl thanks - I would expect if depth
is being used that it gets set during rebuild!
so I think that's how it should work (keen for this to be made to happen!)
from awesome_nested_set.
I just noticed this as well. I've also noticed that calling set_depth_for_self_and_descendants!
on the root doesn't calculate the depth correctly either. At the moment my workaround is to call rebuild!
followed by set_depth!
on each node (which will only work for small numbers of nodes...)
from awesome_nested_set.
Related Issues (20)
- "Unknown key: :polymorphic" error on Rails master (6.1.0.alpha) HOT 1
- Deprecation warning in Rails 6.1 HOT 2
- Ruby 2.7 deprecation warning HOT 3
- Simplification of Iterator#each_with_level HOT 1
- Iterator#each_with_level could return Enumerator if called without block HOT 1
- DEPRECATION WARNING in Rails 5.1 HOT 2
- Scoping rebuild to 'current_user' HOT 2
- Root returns the wrong result for scoped sets
- Rails 6.1 destroy problem with touch: true causes FrozenError HOT 2
- ruby 3.0.0: undefined method `arity' for HOT 4
- Let's move CI to GitHub Actions HOT 1
- default_scoped doesn't work in rails 4.0 HOT 5
- Re-ordering Items at Root Level.
- Active Storage Issue HOT 6
- The behavior of `#parent` in `#validate` has changed, is this intentional? HOT 3
- Publish Rails 7 compatible gem HOT 3
- Order By column name now no longer includes the table name when using scope ".roots" HOT 2
- Getting common ancestors / merging ancestors HOT 1
- Moving item to other position
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome_nested_set.