User profile pages with devise - Routing to show action

后端 未结 3 1088
执笔经年
执笔经年 2020-12-31 21:33

Authentication with devise and a separate controller (Users) that is a single \'show\' action

class UsersController < ApplicationController
#before_filter         


        
3条回答
  •  Happy的楠姐
    2020-12-31 22:00

    I think this may help you.

    In "Rails routing from the Outside in",

    For example, you would like /profile to always show the profile of the currently logged in user. In this case, you can use a singular resource to map /profile (rather than /profile/:id) to the show action.

    match "profile" => "users#show", :as => 'profile'
    
    
  • <%= link_to "Profile", profile_path %>
  • That is for private profile page.

    Since the public profile page will be different to private profile page, I would create a profiles controller to show public profiles.

提交回复
热议问题