How to make public profiles with Devise? Defaultly Devise not have public profiles.
-
Please be more specific in your question.Kleber S.– Kleber S.2011-03-24 18:34:07 +00:00Commented Mar 24, 2011 at 18:34
-
I make fork of twitter (for experience). and now have only microblog without friendship and public user profiles. first, how to make user profiles? For example: if I want to see "user_1" profile, I click to his userpic or his name (near his comment) and can see his public profile... How to make it?Pyrchev– Pyrchev2011-03-24 19:07:14 +00:00Commented Mar 24, 2011 at 19:07
2 Answers
The best way to go about doing this is to add another controller, in this case most likely called users controller and defining a show action within that controller. In your routes.rb file you can define a route that sends a person seeking that user's profile to that controler action.
It would look like this
#in your routes.rb file
get '/users/:id', :to => "users#show", :as => :user
#in your users controller
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
end
Then you obviously need to define a view that corresponds to this action in your views/users folder. (called show.html.erb if you use erb templates).
Now you can use <%= link_to(@user) do%>
In any situation you would like to link back to this public user profile.