Hi, I''ve got a design which allows two objects in a HABTM, for example, an artist and cd''s; in that the artist can appear on many cds and many cds have the artist. to make the association i''ve been using @cd.artist << @artist but i don''t know how to do the opposite. how do i remove the artist from a cd? if I attempt to simply do @cd.artist.find(3).destroy it complains about not being able to find an artist_id. can anyone help? thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think i''ve just cracked it @cd.artist.delete(@artist) this seems to working nicely. On Jan 9, 9:26 pm, hiddenhippo <reda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''ve got a design which allows two objects in a HABTM, for example, an > artist and cd''s; in that the artist can appear on many cds and many > cds have the artist. to make the association i''ve been using > > @cd.artist << @artist > > but i don''t know how to do the opposite. how do i remove the artist > from a cd? if I attempt to simply do > > @cd.artist.find(3).destroy it complains about not being able to find > an artist_id. > > can anyone help? > > thanks--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
or it appears that you can @cd.artists.clear then i can rebuild the association again On Jan 9, 9:35 pm, hiddenhippo <reda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think i''ve just cracked it > > @cd.artist.delete(@artist) > > this seems to working nicely. > > On Jan 9, 9:26 pm, hiddenhippo <reda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I''ve got a design which allows two objects in a HABTM, for example, an > > artist and cd''s; in that the artist can appear on many cds and many > > cds have the artist. to make the association i''ve been using > > > @cd.artist << @artist > > > but i don''t know how to do the opposite. how do i remove the artist > > from a cd? if I attempt to simply do > > > @cd.artist.find(3).destroy it complains about not being able to find > > an artist_id. > > > can anyone help? > > > thanks--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---