簡體   English   中英

設計+主動管理重定向

[英]Devise + Active Admin Redirect

我無法為我的應用程序設置重定向。 用戶應該轉到他們的個人資料(用戶/節目),管理員應該去管理儀表板..我該如何設置?

目前收到以下錯誤:

 NameError in ActiveAdmin::Devise::SessionsController#create

    undefined local variable or method `admin' for #<ActiveAdmin::Devise::SessionsController:0x007febe12667e8>

應用控制器

def after_sign_in_path_for(resource_or_scope)
   if admin
   redirect_to admin_dashboard_path
  else
   @user
  end
 end
end

您沒有要訪問的admin變量,您需要檢查您所提供的參數是什么。

def after_sign_in_path_for(resource)
  stored_location_for(resource) ||
    if resource.is_a?(Admin)
      admin_dashboard_path
    else
      user_path(resource)
    end
end

你也應該不是這個方法里面重定向,它應該只返回設計可以使用路徑。

if resource.class == User
  root_path
elsif resource.class == AdminUser
  admin_root_path
else
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM