我正在尝试在我的 rails api 后端同时实现 devise_token_auth 和 Active Admin。
devise_token_auth FAQ上有非常清晰的说明,解释了如何一起实现这两者——它需要两个不同的应用程序控制器类。
# app/controllers/api_controller.rb
# API routes extend from this controller
class ApiController < ActionController::Base
include DeviseTokenAuth::Concerns::SetUserByToken
end
# app/controllers/application_controller.rb
# leave this for ActiveAdmin, and any other non-api routes
class ApplicationController < ActionController::Base
end
我的应用程序中有这两个控制器,但我不知道如何从它们继承 Active Admin 和 devise_token_auth 的控制器。
我确定我在这里遗漏了一些基本的东西,因为在我在 StackOverflow 上看到的所有关于此的答案中,似乎假设我知道如何做到这一点。
任何人都可以帮忙吗?
编辑:
重申问题,因为我认为我第一次不清楚。现在,Active Admin 和 devise_token_auth 都在使用 ApplicationController,尽管我也创建了 ApiController。如何让 devise_token_auth 使用 ApiController?