【发布时间】:2017-08-10 13:22:27
【问题描述】:
我的 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
当我做 rake 路线时,我也看到了
network_show_user_profile GET /network/registrations/show(.:format) network/registrations#show
但是当我尝试访问路径 /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]
任何关于我做错了什么的帮助将不胜感激。谢谢。
【问题讨论】:
标签: ruby ruby-on-rails-4 devise