closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

Cannot preload self_and_descendants

Open tulak opened this issue 12 years ago • 1 comments

When trying to load hash_tree as much effectively as can I came into an issue. In model I have set order option act_as_tree order: 'name' And then when trying to call Right.includes(:self_and_descendants) mysql throws error:

Unknown column 'name' in 'order clause

That's because ActiveRecord are trying to preload rIght_hierarchies without joining the model (Right) table.

I triet to dig into the code and find the bug. But only found that in closure_tree/model.rb there is _ct.has_many_with_order_option when defining has_many association on model.

Couldn't find out the way how to implement it to work with preloading and also preserve ordering feature on preloaded models. Any ideas ?

tulak avatar Aug 02 '13 14:08 tulak

+1

viktorchukhantsev avatar May 23 '18 13:05 viktorchukhantsev