how about album.photos{|photo| photo.destroy} ? I''m not sure if that
removes
the correct relationships though. You still might need that
album.photos.clear.
RSL
On 2/9/07, Aryk Grosz
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> I know this is probably stupidly simple, but I can''t seem to
figure it
> out.
>
> I have a many-to-many association using HABTM. Im trying to clear all
> the stuff in the join table and call destroy on all the joined items.
>
> For example if I have a many to many for albums and photos,
>
> def method
> album=Album.find(4)
> album.photos.clear
>
> # NOW HOW DO I DESTROY ALL THOSE PHOTOS?
>
> end
>
> The things I thought would work didn''t.
>
> Any ideas.
>
> Thanks in advance. Aryk
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---