Reputation: 244
I am getting this error:
ActionController::RoutingError at /show
uninitialized constant UserController
I have checked my routes, and controller several times and they seem fine so I will post them below
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
def user_params
params.require(:user).permit(:image, :name)
end
end
the route:
get 'index' => 'users#index'
get 'show' => 'user#show'
the attempted link to the show page from the index view:
<h4 class="media-heading"><%= link_to user.name, show_path %></h4>
Thanks for the help, will gladly post more info if needed.
Upvotes: 0
Views: 145
Reputation: 52357
get 'show' => 'user#show'
should be get 'show', to: 'users#show'
You don't have show
action in your controller
I would use RESTful routes, which is simply:
resources :users
# this will generate routes for you
You can specify which actions you want, or which you want to restrict using only
or except
options as @D-Side says in comments
Upvotes: 3