Skip to content

Cannot preload self_and_descendants #70

Open
@tulak

Description

@tulak

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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions