Reputation: 63
Users need have their own profile pages
Plus other users need to be able to view anyone else's profile page
I need to be able to link to profile pages in another gem, for example I can click on a post that a user has made (stories gem) and view the poster's profile.
I found a tutorial https://github.com/danweller18/devise/wiki/Allow-Users-to-View-Profile-and-List-All-Users
But this claims to only allow a user to view their own profile. How exactly do I go about to do this (view other's profile)
Upvotes: 0
Views: 193
Reputation: 6388
Well,
This is the most common situation, in your routes you need something like this
get user/:user_id/profile
then on your view you can do something like
if current_user.id == params[:user_id]
# your content when the user is the same
else
# content for others
Also, you can try to do this on the controller and render different content
Upvotes: 0
Reputation: 2775
You can view other people's profile, since there is a user's :id params in the route. To link to a user's profile, use:
// using user's name as params
<%= link_to user_path(@user.name) %>
Or
// using user's id as params
<%= link_to user_path(@user) %>
Upvotes: 1