Forum: Ruby on Rails delete all with has_many

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2009-02-27 07:59
(Received via mailing list)
Im not sure using :dependent => delete_all is correct here but I want
to delete all the ApptEdits when an Appointment is updated in a
certain situation.  so i have:

@appt_to_edit.update_attributes(appointment_info)

and then i want to do something like:

@appt_to_edit.appt_edits.destroy

but this does not work.  i was thinking about something like
using :dependent => :delete_all, but i only want to do this after a
specific update_attributes call and not every one so i dont think this
is appropriate.  what is the best way to write the equivalent to the
pseudocode: @appt_to_edit.appt_edits.destroy?
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-02-27 12:12
(Received via mailing list)
@appt_to_edit.appt_edits.destroy_all

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
This topic is locked and can not be replied to.