Remove instance of model and its associations

I'm a newb with a quick question.

I have a model
class Call
          has_many :visits
and
class Visit
          belongs_to :call

If I delete a call will it automatically delete the associated
visits??
Any help will be greatly appreciated

I'm a newb with a quick question.

I have a model
class Call
         has_many :visits

  has_many :visits, :dependent => :destroy

this should do the trick.

Best.
Mike

I'm a newb with a quick question.

I have a model
class Call
         has_many :visits
and
class Visit
         belongs_to :call

If I delete a call will it automatically delete the associated
visits??

Sorry, I was too quick on the draw with the last email.

The association you have will not delete the visits. The last message
I posted will destroy associated visits when you destroy the call.

If you don't want AR callbacks to fire on the associated vists you can
use has_many :visits, :dependent => :delete_all

Best.
Mike

Mike - Thank you for your response so I take it that if I have say 20
calls and call with call.id = 5 and if
there are say 11 visits with various visit.id's but with their call_id
= 5 linking them to the above call
then when I execute the delete action for call with id=5 then it will
be deleted along with it's 11 visits
then I should use the first one you said

has_many :visits, :dependent => :destroy ???

Thanks again

Mike - Thank you for your response so I take it that if I have say 20
calls and call with call.id = 5 and if
there are say 11 visits with various visit.id's but with their call_id
= 5 linking them to the above call
then when I execute the delete action for call with id=5 then it will
be deleted along with it's 11 visits
then I should use the first one you said

has_many :visits, :dependent => :destroy ???

From the API http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
:

dependent - If set to :destroy all the associated objects are
destroyed alongside this object by calling their destroy method. If
set to :delete_all all associated objects are deleted without calling
their destroy method. If set to :nullify all associated objects’
foreign keys are set to NULL without calling their save callbacks.
*Warning:* This option is ignored when also using the :through option.

Best.
Mike

Thank you mike so very much - it worked like a charm. One more
itteration complete
Owen