HEllo all, Kindly look into the below query @access_senders = GroupUser.find_by_sql "select distinct user_id from group_users where group_id in (SELECT group_id FROM group_users where user_id=2)" when i inspect the @access_senders i get the below [#<GroupUser user_id: 2>, #<GroupUser user_id: 41>, #<GroupUser user_id: 3518>, #<GroupUser user_id: 3519>, #<GroupUser user_id: 3520>, #<GroupUser user_id: 352 1>, #<GroupUser user_id: 3522>, #<GroupUser user_id: 3523>] now i want to append 3 into the above result set...#<GroupUser user_id: 3> is it poosible to do ... pls help me up -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You could union it in the sql or do this in ruby: @access_senders << GroupUser.new(:user_id => 3) Cheers Luke -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 March 2010 09:57, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> HEllo all, > > Kindly look into the below query > > @access_senders = GroupUser.find_by_sql "select distinct user_id from > group_users where group_id in (SELECT group_id FROM group_users where > user_id=2)" > > when i inspect the @access_senders i get the below > > [#<GroupUser user_id: 2>, #<GroupUser user_id: 41>, #<GroupUser user_id: > 3518>, > #<GroupUser user_id: 3519>, #<GroupUser user_id: 3520>, #<GroupUser > user_id: 352 > 1>, #<GroupUser user_id: 3522>, #<GroupUser user_id: 3523>] > > now i want to append 3 into the above result set...#<GroupUser user_id: > 3>Can you provide the model relationships (has_many and so on) and what you are trying to achieve in words rather than sql? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.