0
votes

I am building a Follow system for my first app, based on Michael Hartl's chapter 11 tutorial (http://ruby.railstutorial.org/chapters/following-users#top). On user pages, it displays # of followers and # of following. But when I hover over the link to followers or following on user profiles, it is directed to link to localhost:3000/users/1/followers or localhost:3000/users/1/following. This is correct. But I click either link, I get the following error listed below. Thanks for helping!

Routing Error
uninitialized constant UsersController

routes.rb

get "user/show"

devise_for :users
match 'users/:id' => 'user#show', as: :user

resources :users do
  member do
    get :following, :followers
  end
end

user_controller.rb

def following
  @title = "Following"
  @user = User.find(params[:id])
  @users = @user.followed_users.paginate(page: params[:page])
  render 'show_follow'
end

def followers
  @title = "Followers"
  @user = User.find(params[:id])
  @users = @user.followers.paginate(page: params[:page])
  render 'show_follow'
end
1

1 Answers

5
votes

Change your file name from user_controller.rb to users_controller.rb

If you're getting the error ActionView::MissingTemplate in Users#following Missing partial users/user then that's exactly where you should look, views/users/_user.html.erb - do you have this file? Have you named it correctly?