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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/10/06, Josh <jjkiesch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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.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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 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 -~----------~----~----~----~------~----~------~--~---
Josh Kieschnick 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 -- 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 -~----------~----~----~----~------~----~------~--~---