Ruby on rails 活动管理员在登录后重定向

Ruby on rails 活动管理员在登录后重定向,ruby-on-rails,ruby-on-rails-3,activeadmin,Ruby On Rails,Ruby On Rails 3,Activeadmin,当管理员登录时,它会自动重定向到主主页(即不是管理员仪表板)。我不知道它为什么会这样或者如何改变它 routes.rb ActiveAdmin.routes(self) devise_for :admin_user, ActiveAdmin::Devise.config get "guidelines/topic" get "guidelines/topichospital" get "guidelines/topicspecialty" get "guidelines

当管理员登录时,它会自动重定向到主主页(即不是管理员仪表板)。我不知道它为什么会这样或者如何改变它

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'
我的应用程序_controller.rb在用户登录后已更改为重定向(但不应为管理员登录)-这是问题所在吗

include PublicActivity::StoreController
  protect_from_forgery

def after_sign_in_path_for(resource)
 favourites_path
end

hide_action :current_user

多亏了齐皮,我找到了答案。在admin_controller.rb中,我添加了:

def after_sign_in_path_for(resource)
     admin_dashboard
end
我必须这样做:

class ActiveAdmin::Devise::SessionsController
  def after_sign_in_path_for(resource)
    admin_dashboard_path
  end
end
来解决这个问题


如果您需要,它还提供了一些定制的可能性。

控制器中放置
登录
操作的位置是什么?已从应用程序控制器添加-是吗?我在
def after_sign_in_path_中为您应该编写的方法使用design,而不是
favorites_path
,您希望它将您重定向到该方法。我从未使用过Deviate,因此我不确定这是否正确,但请尝试将
收藏夹路径
替换为
管理根路径
。使用rake路由查看所有路由,并在方法中使用
\u path
后缀更改方向,但这不只是在用户登录后重定向吗?我想让普通用户登录重定向到Favorities_pathOh,对不起,正如我说的,我从未使用过Desive。尝试找出管理员的登录操作在哪里,并更改那里的重定向路径。要执行此操作,请在active\u管理员初始化器中使用config.root\u to。
if resource.class == User
  root_path
elsif resource.class == AdminUser
  admin_root_path
else
end