Calling destory on HABTM clear

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs