# Disassociating relationships

**URL:** <https://www.ruby-forum.com/t/disassociating-relationships/71698>\
**Category:** Rails\
**Created:** [October 10, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/disassociating-relationships/71698 "2006-10-10T22:09:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [October 10, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/disassociating-relationships/71698/1 "2006-10-10T22:09:02Z")

</div>

in my app, i find a bunch of users in a group with the following line  
of code:

group\_users = Group.find(params[:id]).users

i need to take this group and add some users to it, but i found out the  
hard way that

group\_users \<\< new\_user

does not work the way i want it to. instead of just adding a user to  
the collection of users i have, it also adds the user to the group that  
i originally pulled the users from.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [October 10, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/disassociating-relationships/71698/2 "2006-10-10T22:29:05Z")

</div>

On 10/10/06, Josh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> does not work the way i want it to. instead of just adding a user to  
> the collection of users i have, it also adds the user to the group that  
> i originally pulled the users from.

What exactly are you trying to accomplish? Why would you want add a  
user to your group\_users list who is not a user in that group?

– James

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [October 10, 2006, 10:39pm UTC](https://www.ruby-forum.com/t/disassociating-relationships/71698/3 "2006-10-10T22:39:07Z")

</div>

i basically want to email all of the users in the group + the person  
who created the task + the assignee

i was just trying to add those individual users and send an email to  
all of the unique users in that collection.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [October 11, 2006, 1:43am UTC](https://www.ruby-forum.com/t/disassociating-relationships/71698/4 "2006-10-11T01:43:47Z")

</div>

Josh K. wrote:

> i basically want to email all of the users in the group + the person  
> who created the task + the assignee
> 
> i was just trying to add those individual users and send an email to  
> all of the unique users in that collection.

You just want a simple array of users. Looks like Rails has overridden  
\<\< on the array they’re returning to you. Try cloning the array you get  
back from ActiveRecord:

group\_users = Group.find(params[:id]).users.dup  
group\_users \<\< new\_user
