Hi all, I have a has_and_belongs_to_many relationship with 2 tables (users - users_teams, teams) Can I delete a user from a team with 1 function? I now first delete the user from users_teams and then from teams. Can''t this be done with one method? Thanks Stijn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tarscher wrote:> I have a has_and_belongs_to_many relationship with 2 tables (users - > users_teams, teams) > > Can I delete a user from a team with 1 function? I now first delete > the user from users_teams and then from teams. Can''t this be done with > one method?team.users.delete(user) -- Josh Susser http://blog.hasmanythrough.com/ -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, thanks for the reply
Though I still don''t get it to work
When I do
team = Node.find(teamid)
user = User.find(userid)
team.users.delete(user)
ActiveRecord only deletes records in the users_teams table and not
users table. Is this not possible with 1 function?
Thanks
Stijn
On 4 feb, 17:44, Josh Susser
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Tarscherwrote:
> > I have a has_and_belongs_to_many relationship with 2 tables (users -
> > users_teams, teams)
>
> > Can I delete a user from a team with 1 function? I now first delete
> > the user from users_teams and then from teams. Can''t this be
done with
> > one method?
>
> team.users.delete(user)
>
> --
> Josh Susserhttp://blog.hasmanythrough.com/
>
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---