2015-12-22 76 views
-1

我想在用户登录后设置根URL,但问题出在用户登录后,它们被重定向到主页但不是我想要的页面。这是代码。没有路由到rails中的命名空间控制器

devise_scope :user do 
    authenticated :user do 
     # root to: 'dashboard#index', module: 'client' 
     namespace :client do 
     root to: 'dashboard#index', as: :dashboard 
     end 
    end 
    unauthenticated :user do 
     root to: 'devise/registrations#new', as: :unauthenticated_root 
    end 
    end 

用户应该被重定向到/ client/index,而不是被重定向到\。

+1

设计已经与after_sign_in_path_for方法处理这一点。只需在你的控制器中覆盖该方法(大概是ApplicationController),并让它返回你想要的任何路径。 –

+0

@TomL,是的,我现在已经做到了 – Raaz

回答

0

我找到了一种让它工作的方法。

namespace :client do 
    get 'dashboard/index' 
    end 

    devise_for :users, class_name: 'FormUser', controllers: { omniauth_callbacks: 'omniauth_callbacks', registrations: 'registrations' } 
    devise_scope :user do 
    # authenticated :user do 
    # # root to: 'dashboard#index', module: 'client' 
    # namespace :client do 
    #  root to: 'dashboard#index', as: :dashboard 
    # end 
    # end 
    unauthenticated :user do 
     root to: 'devise/registrations#new', as: :unauthenticated_root 
    end 
    end 

如果有更好的办法,请让我知道

相关问题