跳过 ActiveAdmin 中特定成员操作的身份验证

Skip authentication for specific member action in ActiveAdmin

我正在尝试跳过我创建的自定义 ActiveAdmin 成员操作的身份验证。这是我一直在尝试的方法,但它仍将我带到登录页面。

ActiveAdmin.register Foo, as: "Foos" do

  controller do
    skip_before_action :authenticate_admin_user!, only: :bar
  end

  member_action :bar, method: :get do
    # render something
  end

end

版本:

  1. 看看this gist
  2. self.filtersself.before_filters 方法放入 controller do 块中。
  3. 在这些方法之后添加 binding.pry 并重新启动应用程序服务器 - 这应该在绑定时停止。
  4. 键入 filters(:before),您将看到一个回调列表。
  5. 找到负责身份验证的回调,例如authenticate_active_admin_user.
  6. skip_before_filter :authenticate_active_admin_user 添加到 controller do 块。
  7. 休息一下:)