0

How to make public profiles with Devise? Defaultly Devise not have public profiles.

2
  • Please be more specific in your question. Commented 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? Commented Mar 24, 2011 at 19:07

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You could make a view that will show the user's info.

This view should be in one of your controllers (users controller for example)

Grab the info in the controller from the User model, and display it in the view.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.