You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm receiving the following error then calling the tree_view method. I am using uuids for primary keys, but that might not be the problem here. It looks like it's dying because the result from hash_tree_scope isn't properly sorted by depth.
Adding
order by depth
to line 38 of /lib/closure_tree/hash_tree.rb kinda makes it "work", but I know that's not the correct fix. Wish I could fix it properly, but I'm still really new to ruby and rails.
Loading development environment (Rails 4.0.0)
irb(main):001:0> Organization.tree_view
NoMethodError: undefined method `tree_view' for #<Class:0x007ff1c087cd50>
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
from (irb):1
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):002:0> Organization.hash_tree
Organization Load (8.0ms) SELECT "organizations".* FROM "organizations" INNER JOIN (
SELECT descendant_id, MAX(generations) as depth
FROM "organization_hierarchies"
GROUP BY descendant_id
) AS generation_depth
ON "organizations".id = generation_depth.descendant_id
NoMethodError: undefined method `[]=' for nil:NilClass
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/closure_tree-4.2.7/lib/closure_tree/hash_tree.rb:52:in `block in build_hash_tree'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:13:in `each'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:13:in `each'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/closure_tree-4.2.7/lib/closure_tree/hash_tree.rb:47:in `build_hash_tree'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/closure_tree-4.2.7/lib/closure_tree/hash_tree.rb:23:in `hash_tree'
from (irb):2
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /home/vagrant/rubies/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
The text was updated successfully, but these errors were encountered:
I was having this issue too. A pull request #71 that fixes this have been merged into the master but It wasn't released yet as a new version on rubygems.
I'm receiving the following error then calling the tree_view method. I am using uuids for primary keys, but that might not be the problem here. It looks like it's dying because the result from hash_tree_scope isn't properly sorted by depth.
Adding
order by depth
to line 38 of /lib/closure_tree/hash_tree.rb kinda makes it "work", but I know that's not the correct fix. Wish I could fix it properly, but I'm still really new to ruby and rails.
The text was updated successfully, but these errors were encountered: