I am guessing destrou uses the relationships in your model file to
delete
the has_one and has_many relationships and delete only deletes the
current
object
yes this is true destroy does find all the relations…and ‘destroys’
them…wooot
sweet, now I love this AR stuff
You may need to give AR a prod if you want all relations destroyed. In
your
has_many/has_one/HABTM relationships you need to include :dependent =>
:destroy_all
yes this is true destroy does find all the relations…and ‘destroys’
them…wooot
sweet, now I love this AR stuff
You may need to give AR a prod if you want all relations destroyed. In
your
has_many/has_one/HABTM relationships you need to include :dependent =>
:destroy_all
:dependent => :destroy_all
must be added on all of them like this?
Slightly longer answer: destroy will not automatically destroy
associated records. Rather than have Rails default to destroying your
data, it sensibly refrains from rampages of destruction and leaves the
owner of the data to decide its fate.
Basically, when you call ‘destroy’ on an object, it will not
automatically remove the associated records unless you specifically ask
it to in the ‘has_many’ declaration.
askegg’s long answer is quite poetic but a little complicated :0)
What he said
You don’t want a framework to assume you want all related data to be
destroyed.
Basically, when you call ‘destroy’ on an object, it will not
automatically remove the associated records unless you specifically ask
it to in the ‘has_many’ declaration.
askegg’s long answer is quite poetic but a little complicated :0)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.