Devise within namespace

后端 未结 6 567
慢半拍i
慢半拍i 2021-01-30 03:22

I\'m trying to split my rails project in a front-end for regular users and a back-end for admins. Therefore i have created a namespace \'admin\' so that i can easily control adm

6条回答
  •  面向向阳花
    2021-01-30 03:45

    How about specifying devise the path to take, place this outside your namespace.

    devise_for :users, path: 'admins'
    

    This will generate the following routes

    new_user_session          GET      /admins/sign_in(.:format)          devise/sessions#new
    user_session              POST     /admins/sign_in(.:format)          devise/sessions#create
    destroy_user_session      DELETE   /admins/sign_out(.:format)         devise/sessions#destroy
    user_password             POST     /admins/password(.:format)         passwords#create
    new_user_password         GET      /admins/password/new(.:format)     passwords#new
    edit_user_password        GET      /admins/password/edit(.:format)    passwords#edit
                              PUT      /admins/password(.:format)         passwords#update
    cancel_user_registration  GET      /admins/cancel(.:format)           registrations#cancel
    user_registration         POST     /admins(.:format)                  registrations#create
    new_user_registration     GET      /admins/sign_up(.:format)          registrations#new
    edit_user_registration    GET      /admins/edit(.:format)             registrations#edit
                              PUT      /admins(.:format)                  registrations#updat
                              DELETE   /admins(.:format)                  registrations#destroy
    

    You don't have to change anything in that case, if this is what you are looking for.

    Happy Coding :)

提交回复
热议问题