5

我在我的设计控制器中添加动作时遇到了一些麻烦。registrations_controller我在这样的文件夹中创建了一个名为的控制器users/

class Users::RegistrationsController < Devise::RegistrationsController

而且,还有我的路线文件:

root to: 'home#index'

devise_for :users
devise_scope :users do
    get 'users/profil/:id', to: 'users/registrations#profil', as: 'profil'
end

我看到以下错误:

Unknown action
Could not find devise mapping for path "/users/profil/1"
This may happen for two reasons: 1) You forgot to wrap your route inside the scope block. For example: devise_scope :user do get "/some/route" => "some_devise_controller" end 2) You are testing a Devise controller bypassing the router.

我的代码有什么问题?

4

1 回答 1

6

尝试以下操作:

    devise_scope :user do
       get 'users/profil/:id', to: 'users/registrations#profil', as: 'profil'
    end
    devise_for :users, :controllers => {:registrations => "users/registrations"}
    resources :users 

此外,您无需命名控制器Users::RegistrationsController,将其命名为RegistrationController保持继承,就像您拥有的一样Devise::RegistrationsController

于 2013-11-12T22:24:30.940 回答