ruby on rails - Acts_as_follower display follows RoR -
i using ruby gem called acts_as_follower
my code:
user.rb
class user < applicationrecord acts_as_followable acts_as_follower end users_controller.rb
def follow @user = user.find(params[:id]) current_user.follow(@user) redirect_to root_path end def unfollow @user = user.find(params[:id]) current_user.stop_following(@user) redirect_to root_path end followers.html.erb
<% @user.followers.each |user| %> <div class="panel panel-default col-md-offset-3 col-md-6"> <br> <div class="panel panel-heading"> <%= avatar_for(user, size: 50) %> <h1> <%=link_to user.name, user %></h1> </div> </div> routes.rb
#followers resources :users member :follow :unfollow end end how display users follow?
how display users follow?
i believe method want all_following
user.all_following returns array of every followed object user, can collection of different object types, eg: user, book
so, below should work
@user.all_following
Comments
Post a Comment