2013-03-13 58 views
2

當管理員登錄時,它會自動重定向到主主頁(即不是管理控制檯)。我不知道爲什麼它這個還是怎麼改...登錄後激活管理員重定向

的routes.rb

ActiveAdmin.routes(self) 

    devise_for :admin_user, ActiveAdmin::Devise.config 


    get "guidelines/topic" 
    get "guidelines/topichospital" 
    get "guidelines/topicspecialty" 
    get "guidelines/favourite" 
    get "profiles/show" 
    get "guidelines/show" 

root :to => 'guidelines#index' 

我application_controller.rb已更改用戶登錄後重定向(但不應該是管理員登錄) - 這是問題嗎?

include PublicActivity::StoreController 
    protect_from_forgery 

def after_sign_in_path_for(resource) 
favourites_path 
end 

hide_action :current_user 
+2

什麼在你的控制器裏放置了'login'動作?已從應用程序控制器添加了 – Zippie 2013-03-13 01:06:03

+0

- 是嗎?在'def after_sign_in_path_for'方法中使用devise – tessad 2013-03-13 01:11:26

+0

,您應該寫入,而不是'favourites_path'您希望它重定向到。我從來沒有使用過設計,所以我不確定這是否正確,但嘗試用'admin_root_path'替換'favourites_path'。使用耙路徑查看所有路線,然後在方法 – Zippie 2013-03-13 01:17:48

回答

2

感謝Zippie我找到了答案。在admin_controller.rb我說:

def after_sign_in_path_for(resource) 
    admin_dashboard 
end 
+2

要做到這一點Rails 4.1和ActiveAdmin 1.0.0.pre,請使用active_admin初始程序中的config.root_to。 – 2014-12-20 20:22:53

1

我不得不這樣做:

class ActiveAdmin::Devise::SessionsController 
    def after_sign_in_path_for(resource) 
    admin_dashboard_path 
    end 
end 

來解決該問題。

如果您需要它也可以打開一些定製的可能性。

0
if resource.class == User 
    root_path 
elsif resource.class == AdminUser 
    admin_root_path 
else 
end 
相關問題