2015-12-22 75 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 

如果有更好的辦法,請讓我知道

相關問題