Authentication with devise and a separate controller (Users) that is a single \'show\' action
class UsersController < ApplicationController
#before_filter
If you want to see the current logged in users profile make sure you are logged in.
add the before_filter :authenticate_user!
in users controller.
Then in header link <li><%= link_to "Profile", current_user %></li>
I think this may help you.
In "Rails routing from the Outside in",
For example, you would like /profile to always show the profile of the currently logged in user. In this case, you can use a singular resource to map /profile (rather than /profile/:id) to the show action.
match "profile" => "users#show", :as => 'profile'
<li><%= link_to "Profile", profile_path %></li>
That is for private profile page.
Since the public profile page will be different to private profile page, I would create a profiles controller to show public profiles.
You just need to pass User
instance as a parameter to link_to
if you want it to link to given user's show
page. So if you want to link to currently logged in user's profile in Devise, you just need:
<li><%= link_to "Profile", current_user %></li>