Skip to content

has_closure_tree_leaf #291

Open
Open
@cybernetlab

Description

@cybernetlab

Hi, Is where an analogue of has_closure_tree_root for asscoiations to leaf nodes of tree? I have following structures and want to organize their with closure_tree:

  1. Localities (like: country, region, city) - tree structure
  2. Users - each user has a link to lowerst-level node of localities in user.locality_id (for example - to city)

I want to be able to select all users with preloaded list of localities (all ancesotrs of leaf) for each user (for example: user.address => [city, region, country]) with a minimal number of SQL queries. Any ideas?

Looks like a feature request but may be someone gives me a hint for a temporary solution?

UPD: Also I have attempted to solve this with awesome nested set and I was able to make right SQL request but I have no idea how to preload a list of records from query result into user.address field because I've belongs_to association with user.locality_id and wants to have a sort of has_many association to same table (localities) in user.address.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions