Description
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
:
- Localities (like: country, region, city) - tree structure
- 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!