0
我在routes.rb中找不到設計映射路徑
devise_for :users, controllers: { registrations: "network/registrations",sessions: 'network/sessions', passwords: 'network/passwords' }
devise_scope :user do
get "registrations/show" => "network/registrations", as: :show_user_profile
end
定義了以下路線,當我做耙路線我也看到
network_show_user_profile GET /network/registrations/show(.:format) network/registrations#show
但是,當我試圖訪問路徑/網絡/註冊/節目
我得到下面的異常
找不到設計映射路徑「/ network/registrations/show」。 可能發生這種情況的原因有兩個:
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.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
我試圖修改routes.rb中,並加入
devise_scope :user do
get 'user_profile' => 'registrations#search', :as => 'user_profile'
end
,當我訪問user_profile路,我得到的錯誤
The action 'show' could not be found for Network::RegistrationsController
但當我添加動作顯示到控制器我再次得到相同的異常消息
無法找到路徑「/ network/registrations/show」的設計映射。 可能發生這種情況的原因有兩個:
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.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
任何幫助,以什麼我做錯了,將不勝感激。謝謝。
嗨nimish,仍然是同樣的錯誤。 –
@ opensource-developer請參閱最新的答案 –
嗨@nimish再次爲您的答覆。但它仍然給我同樣的錯誤,不知道我在做什麼錯誤 –