# Acts\_as\_tree / acts\_as\_nested\_set

**URL:** <https://www.ruby-forum.com/t/acts-as-tree-acts-as-nested-set/79352>\
**Category:** IT\
**Created:** [December 14, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/acts-as-tree-acts-as-nested-set/79352 "2006-12-14T14:51:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ba0ec/32.png) [@tele](https://www.ruby-forum.com/u/tele)\
**Post date:** [December 14, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/acts-as-tree-acts-as-nested-set/79352/1 "2006-12-14T14:51:43Z")

</div>

Ciao a tutti,

ho delle difficolta’ a gestire una struttura dati con Rails.  
a dire il vero non ci riesco proprio.

sto provando con acts\_as\_tree e acts\_as\_nested\_set ma ho 3 tabelle e non  
una… non so quindi come fare.

Ok passo ad illustrarvi la struttura dati estremamente semplice:

numerations(id,number,code,data\_cut\_over)  
users(id,lid)  
associations(numeration\_id,user\_id)

select n.number,u.lid from associations as a, numerations as n, users as  
u where n.id = a.numeration\_id and u.id = a.user\_id;  
±-----------±---------------+  
| number | lid |  
±-----------±---------------+  
| 2104491080 | 396006660080 |  
| 2104491081 | 396006660081 |  
| 2104491082 | 396006660082 |  
| 2104491083 | 396006660083 |  
| 2104491082 | 396006660088 |  
±-----------±---------------+

vorrei rappresentarli come un tree.  
listare tutti i numeri in numerations e dove c’e’ un’associazione  
visualizzarle come segue:

21104491080  
|\_ 396006660080  
21104491081  
|\_ 396006660081  
21104491082  
|\_ 396006660082  
|\_ 396006660088

Quello che mi blocca e’ che con acts\_as\_tree non posso specificare o  
fare “join” per il parent da altre tabelle.

mi sapete consigliare qualcosa?

altrimenti mi conviene farlo a mano senza usare acts\_as\_tree o  
acts\_as\_nested\_set.

thanks

:tele
