Reputation: 2809
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.
Upvotes: 0
Views: 3459
Reputation: 6485
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) %>
Upvotes: 6
Reputation: 21863
Your route should be
match 'users/:id', :to => 'users#show', :as => :profile
^^^^
Upvotes: 0