未定义的方法 `destroy_user_session_path' 用于具有 cancancan 和巫术的活动管理员

undefined method `destroy_user_session_path' for active admin with cancancan and sorcery

嗨,我正在开发 rails 4.2.4 应用程序,我正在使用 sorcery 进行身份验证,使用 cancancan 进行授权。到目前为止一切顺利,我可以登录,用户也可以这样做....我我正在尝试为管理仪表板添加 activeadmin 到目前为止我几乎设置了所有内容但是当我以管理员身份登录应用程序时启动 link http://localhost:3000/admin 我收到错误:

未定义方法 `destroy_user_session_path' 用于 :ActiveAdmin::Views::TabbedNavigation

这是我的模块:

Activeadmin.rb

ActiveAdmin.setup do |config|

  config.site_title = "title goes here"

  def authenticate_user!
    if !current_user.admin?
     redirect_to new_user_session_path
    end


end

  config.authentication_method = :authenticate_user!
  config.current_user_method = :current_user
  config.logout_link_method = :delete
  config.logout_link_path = :destroy_user_session_path
  config.batch_actions = true
  config.authorization_adapter = ActiveAdmin::CanCanAdapter
  config.localize_format = :long

end

ability.rb

    class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    if user.admin?
      can :read, ActiveAdmin::Page, :name => "Dashboard"
      can :manage, :all
    elsif user.client?
      can :manage, [Act, Do, Fact, Task, T]
      cannot :read, ActiveAdmin::Page, :name => "Dashboard"
    else
      can :read, Activity
    end

    can :manage, UserSessionsController do |user_session|
      user == user_session
    end

    if user.active?
      can :time, Activity
      can :read, ActiveAdmin::Page, :name => "Dashboard"
    end
    can :log_in, User
    can :log_out, User
    can :reset_password, User
  end
end

在会话控制器中销毁

def destroy
    authorize! :log_out, User
    logout
    redirect_to root_url, notice: I18n.t('users.log_out')
  end

任何人都可以指出我如何解决这个问题......被困在这里一段时间......

干杯

所以在进一步调查之后,正确的方法是

config.logout_link_path = :user_session_path

但遗憾的是,ActiveAdmin 目前不支持注销路径中带有 id 的 url。

查看此线程 from the activeadmin owner