更新时间:2023-11-04 15:52:16
我也必须这样做,而且目前还没有内置到设计中.由于最受好评的答案有一个死链接,我想我会在这里发布我的解决方案.
I've had to do this as well, and it's not currently built into devise. Since the answer most upvoted has a dead link, I thought I'd post my solution here.
您需要创建一个 UsersController 并自行构建您的表单和控制器,但是您还需要隔离设计设置的 UsersController.为此,在您的 routes.rb
文件中,将您的 devise_for :users
调用修改为
You need to create a UsersController and built out your forms and controller on your own, but then you also need to isolate the UsersController that devise sets up. To do this, in your routes.rb
file, modify your devise_for :users
call to
devise_for :users, :path_prefix => 'd' # routes for devise modules on User
resources :users # custom admin-type CRUD for users
这会将您所有默认设计处理的路由更改为/d/users/... 并让您拥有/users/... 路径以让您以管理员身份管理用户.
This will change all your default devise-handled routes to /d/users/... and let you have the /users/... path to let you manage users as an admin.
Devise also addresses this in their wiki.