Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_closure_tree_leaf #291

Open
cybernetlab opened this issue Nov 25, 2017 · 0 comments
Open

has_closure_tree_leaf #291

cybernetlab opened this issue Nov 25, 2017 · 0 comments
Labels

Comments

@cybernetlab
Copy link

cybernetlab commented Nov 25, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants