I'm trying to get acts_as_follower working but i'm missing something. A user should be able to Follow another User.
I added the Gem :
gem "acts_as_follower", '~> 0.2.0' #0.2.0 for Rails 4
In my User model i added :
acts_as_follower
acts_as_followable
The User Controller i created looks like this :
class UsersController < ApplicationController
  def show
    @user = User.find(params[:id])
  end
  def follow
    @user = User.find(params[:id])
    current_user.follow(@user)
    redirect_to :back
  end
end
My routes :
App::Application.routes.draw do
  root 'screens#index'
  devise_for :users
  get 'u/:id' => 'users#show', as: :user
  resources :screens, :path => 's' do
    member do
      get :like
      get :unlike
    end
  end
  get "pages/home"
  get "about" => "pages#about"
  get "users/show"
end
now in the routes i have to add the member :follow =>
member do
  get :follow
end
But i'm stuck at this point. I tried a few variations and my link to follow a User is :
<%= link_to "Follow", follow_user_path(@user)%>
and this is giving me the error ->
undefined method `follow_users_path' for #<#<Class:0x007fb4da78e920>:0x007fb4db3facb8>
The Solution was to create a user resource, it works perfectly now =>
resources :users do
    member do
      get :follow
      get :unfollow
    end
  end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With