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.
On 10/10/06, Josh [email protected] 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
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.
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