Say Actor HABTM Movies.
If Actor with id == 25 is associated with a Movie with id == 213:
a = Actor.find(25)
m = Movie.find(213)
then
a.movies.delete(m)
will remove the association. It won''t delete the movie, just unlink
them.
Can short-circuit with
a.movies.delete(Movie.find(213))
Sean Colquhoun wrote:> Thanks to the wonderful advice of everybody here, I finally understand
> how to add records to a HABTM table. You treat it like an array, and
> just use the "<<" concatenator to stick the new record on
at the end.
>
> But how do you delete a record?
>
> i''ve tried to use arr.delete or arr.clear, like in the pickaxe
book, but
> it''s not working. Can anyone give a quick rundown on the basics of
> deleting these kinds of associations?
>
> Thanks!
> sean
--
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
-~----------~----~----~----~------~----~------~--~---