Ruby on Rails + Devise
How to make public profiles with Devise? Defaultly Devise not have public开发者_StackOverflow社区 profiles.
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.
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.
精彩评论