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@googlegroups.com.
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.

Search Discussions

  • Clint at Nov 24, 2011 at 9:06 am
    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 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@googlegroups.com.
    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.
  • Hesham at Nov 25, 2011 at 11:42 am
    Thank you.
    On Nov 24, 1:06 pm, Clint 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 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@googlegroups.com.
    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.
  • Colin Law at Nov 24, 2011 at 9:12 am

    On 24 November 2011 07:01, Hesham 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@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 24, '11 at 7:01a
activeNov 25, '11 at 11:42a
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

3 users in discussion

Hesham: 2 posts Clint: 1 post Colin Law: 1 post

People

Translate

site design / logo © 2021 Grokbase