开发者

How to configure routes for a profile controller?

I'm trying to configure a route to display a profile page about the user.

At the moment, I've created a custom controller for this page using:

I generated my controller using:

rails g controller user-profile

and I made corresponding views.

I'm trying to do something like this:

/us开发者_运维问答er-profile/:id

I'm using devise. How do I configure the route for this?


I would do it this way (the resulting profile will be public):

Add the route:

match "/user-profile/:id" => "user-profile#show"

Add the related action in your controller:

def show
  @user = User.find(params[:id])
end

You're then free to use the @user variable in app/views/user-profile/show.html.erb.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜