I have this code in rp_parts controller in def destroy: @repair_ticket.rp_parts.delete(@rp_part) repair_tickets and rp_parts are HABTM. If I do in the console:>> repair_ticket1.rp_partsI get: => [#<RpPart id: 1, ...">, #<RpPart id: 1,...">, #<RpPart ...">] I only want to delete one of those RpPart id:1, and not both of them. Is it possible? -- 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 -~----------~----~----~----~------~----~------~--~---
repair_tickets and rp_parts are HABTM. If I do:>> repair_ticket1.rp_parts=> [#<RpPart id: 1, ...">, #<RpPart id: 1,...">, #<RpPart ...">] I only want to delete one of those RpPart id:1, and not both of them. Is it possible? How can I do that? -- 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 -~----------~----~----~----~------~----~------~--~---
If you want to remove duplicates from your array you do repair_ticket1.rp_parts.uniq! On Jan 10, 2008 12:14 PM, John Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > repair_tickets and rp_parts are HABTM. > > If I do: > >> repair_ticket1.rp_parts > => [#<RpPart id: 1, ...">, #<RpPart id: 1,...">, #<RpPart ...">] > > I only want to delete one of those RpPart id:1, and not both of them. Is > it possible? How can I do that? > -- > 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 -~----------~----~----~----~------~----~------~--~---