Search code examples
ruby-on-railsroutescontrollers

Devise user paths


I am using devise for my auth and it works great. I need a profile page and I created a controller for Users and have a show method in there which links to show.html.erb and that works once the id is passed.

I want to add a link in the profile to go to the url /users/[:id] but I can't get it to work. I've tried:

match 'users/:id', :to 'users#show', :as => :profile

but I get error saying no action show.

Can anyone give me some advice to get a link to route to their profile.


Solution

  • If you want something to go /users/:id isn't it as simple as:

    routes.rb

    resources :users
    

    view_file.html.erb

    <%= link_to "Bob's profile", user_path(user_id) %>