acts_as_follower rails 4 routing error

So I’m trying to use the acts_as_follower gem with devise but i get the error:

Couldn't find User with 'id'=

The id is blank

my config/routes.rb is

 devise_for :users, controllers: { sessions: "users/sessions" }

  devise_scope :user do
      put "subscribe" => "users/sessions#subscribe"
      put "unsubscribe" => "users/sessions#unsubscribe"
  end

sessions_controller.rb

class Users::SessionsController < Devise::SessionsController
  def subscribe
    @user = User.find(params[:id])
    current_user.follow(@user)
    redirect_to root_path
  end

  def unsubscribe
    @user = User.find(params[:id])
    current_user.stop_following(@user)
    redirect_to root_path
  end
end

when i run ‘rake routes’ i get

       subscribe PUT    /subscribe(.:format)           users/sessions#subscribe
     unsubscribe PUT    /unsubscribe(.:format)         users/sessions#unsubscribe


Source: ruby

Leave a Reply