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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -