简体   繁体   English

设计命名空间 - ActionController :: RoutingError(无路由匹配{:action =>“new”,:controller =>“devise / sessions”})

[英]Devise in namespace - ActionController::RoutingError (No route matches {:action=>“new”, :controller=>“devise/sessions”})

I'm using Devise and everything has been working great, but I am now trying to move things into an 'admin' namespace. 我正在使用Devise,一切都很好,但我现在正试图将事情转移到'admin'命名空间。

I have a route that looks like: 我的路线看起来像:

namespace :admin do
  devise_for :users, :controllers => { :registrations => "admin/users/registrations" }
end

In one of my controllers I have 在我的一个控制器中

before_filter :authenticate_user!

but when that gets called it throws: 但当它被调用时会抛出:

ActionController::RoutingError (No route matches {:action=>"new", :controller=>"devise/sessions"}): 

Any ideas? 有任何想法吗?

As per the Devise documentation (which likely has changed since this posting), you could use the following instructions: 根据Devise文档(自发布以来可能已更改),您可以使用以下说明:

#    ...
#    
#    Notice that whenever you use namespace in the router DSL, it automatically sets the module.
#    So the following setup:
#
#      namespace :publisher do
#        devise_for :account
#      end
#
#    Will use publisher/sessions controller instead of devise/sessions controller. You can revert
#    this by providing the :module option to devise_for.
#    
#    ...

Hope this helps someone. 希望这有助于某人。

I'm doing this: 我这样做:

scope '/admin' do
  devise_for :admins
end

A workaround for this is to use the path option and move devise_for outside of the namespace block: 解决方法是使用path选项并在namespace之外移动devise_for

devise_for :users, :path => '/admin',
                   :controllers => { :registrations => "admin/users/registrations" }
namespace :admin do
  # other resource controllers
end

Perhaps it's not as elegant (or intuitive), but it works for me! 也许它不那么优雅(或直观),但它对我有用!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 设计 - ActionController :: RoutingError(没有路由匹配[GET]“/ confirm”): - Devise - ActionController::RoutingError (No route matches [GET] “/confirm”): Devise :: Sessions#new中的ActionController :: UrlGenerationError-没有路由匹配 - ActionController::UrlGenerationError in Devise::Sessions#new - No route matches ActionController :: RoutingError:没有路由与{:controller =>“ vendors”,:action =>“ vendors”}匹配? - ActionController::RoutingError: No route matches {:controller=>“vendors”, :action=>“vendors”}? ActionController :: RoutingError(没有路由与{:action =>“ show”,:controller =>“ users”,:id => nil}匹配): - ActionController::RoutingError (No route matches {:action=>“show”, :controller=>“users”, :id=>nil}): ActionController :: RoutingError(没有路由匹配{:controller =>“users”,:action =>“profile”}) - ActionController::RoutingError (No route matches {:controller=>“users”, :action=>“profile”}) ActionController :: RoutingError(没有路由匹配“ / user_sessions /…”) - ActionController::RoutingError (No route matches "/user_sessions/…) 测试自定义设计控制器时的ActionController :: RoutingError - ActionController::RoutingError when test custom devise controller 没有路线符合“设计/会话” - No route matches “devise/sessions” Rails设计路由错误 - “无路由匹配”(controller =>“devise / sessions”) - Rails Devise routing error - “No route matches” (controller=>“devise/sessions”) 没有路由匹配{:action =>“ search”,:controller =>“ devise / index”} - No route matches {:action=>“search”, :controller=>“devise/index”}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM