0
votes

I am getting a really frustrating error and I think it is a simple fix. In my header, when I try to include a link called "My Account" that routes to the user's profile, I get:

No route matches {:action=>"show", :controller=>"users"}

Everything else works in terms of signup/in with devise, and I can get to the user profile page after signing in at localhost:3000/users/1

My link code in the view:

<%= link_to "My Account", user_path %>

Also, I get the exact same error when trying to route to the edit user profile page at "edit_user_registration_path":

<%= link_to "Edit Profile", edit_user_registration_path, class: "prof-btn" %>

I also tried:

<%= link_to "Edit Profile", edit_user_registration_path(@user), class: "prof-btn" %>

But same error.

My routes.rb file:

root to: 'static_pages#home' ActiveAdmin.routes(self) devise_for :admin_users, ActiveAdmin::Devise.config devise_for :users resources :users

My users_controller.rb:

class UsersController < ApplicationController

def show
    @user = User.find(params[:id])
end

def create
    @user = User.create(params[:user])
end

def edit
    @user = User.find(params[:id])
end

enter image description here

Any help on this would be appreciated!

1

1 Answers

1
votes

You have to pass in the user to the path helper.

<%= link_to "My Account", user_path(current_user) %>