Ruby Forum Italian Ruby user group > activerecord, oggetto.destroy e figli

Posted by Stefano Sasso (Guest)
on 14.08.2008 09:38
(Received via mailing list)
ciao *,
  da un oggetto activerecord, invocando il metodo .destroy, è 
possibile eliminare anche tutti i figli (ricorsivamente) di tale
oggetto?
cioè, ad esempio, avendo
A:
has_many B

B:
belongs_to A
has_many C

C:
belongs_to B

io vorrei un qualcosa del genere
a=A.find(:first)
a.destroy  che mi elimini anche tutti i B figli di a, e i C figli dei
B figli di a.

è possibile fare ciò, senza usare le FK (on delete cascade) del db?

grazie,
  stefano

--
---------------------------------------------------------------
Per favore non mandate allegati in Word o PowerPoint.
Si veda http://www.fsf.org/philosophy/no-word-attachments.html
Posted by Luca Guidi (Guest)
on 14.08.2008 10:00
(Received via mailing list)
has_many :comments, :depentant => :destroy

--
blog: www.lucaguidi.com
Pro-Netics: www.pro-netics.com
Sourcesense - making sense of Open Source: www.sourcesense.com