I''m using the act_as_followers gem and one of the methods returns an array of all the users that are following a specific user, example: followers = user.all_following What would be the clean way of extracting just the followers.id and placing the results in an array? -- 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.
I am not familiar with act_as_followers, but followeres = user.all_following.map(&:id) is the cleanest I can come up with. On Nov 24, 8:01 am, Hesham <hesham.am...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using the act_as_followers gem and one of the methods returns an > array of all the users that are following a specific user, example: > > followers = user.all_following > > What would be the clean way of extracting just the followers.id and > placing the results in an array?-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 November 2011 07:01, Hesham <hesham.amiri-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using the act_as_followers gem and one of the methods returns an > array of all the users that are following a specific user, example: > > followers = user.all_following > > What would be the clean way of extracting just the followers.id and > placing the results in an array?Have a look through the documentation for the Array class, map or collect may well be useful. Probably working through a ruby book would also be a good idea, have a look at the Pickaxe book. You cannot use rails without a good knowledge of Ruby. 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.
Thank you. On Nov 24, 1:06 pm, Clint <simon.krollpfei...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am not familiar with act_as_followers, but > > followeres = user.all_following.map(&:id) > > is the cleanest I can come up with. > > On Nov 24, 8:01 am, Hesham <hesham.am...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I''m using the act_as_followers gem and one of the methods returns an > > array of all the users that are following a specific user, example: > > > followers = user.all_following > > > What would be the clean way of extracting just the followers.id and > > placing the results in an array?-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.