0

I'm doing a job with acts_as_follower gem that users can follow others users. The documentation says:

To get all of the records that an object is following that have not been blocked use the following

user.all_following
# Returns an array of every followed object for the user, this can be a collection of different object types, eg: User, Book

I did that and I'm stiil getting blocked users on loop.

I tried to put a conditional:

<% if current_user.following?(user) %>

But this line also show blocked users, because even with user blocked, it stiil followin user in the follow model.

Currently my call is like this:

<% current_user.all_following.each do |user| %>

Someone knows how I can definitely prevent blocked users from being listed on loop?

Thanks!

Fernando Aureliano
  • 894
  • 12
  • 35
  • Can you verify the users are indeed blocked? Do they show up on `current_user.blocks` ? If that works, you could put a conditional like... `<% current_user.all_following.each do |user| %>` and in the next line, `<% next if current_user.blocks.include? user %>` – SteveTurczyn Dec 05 '17 at 15:49
  • It works! Thanks! – Fernando Aureliano Dec 06 '17 at 11:42

0 Answers0