我正在使用rails 4.2.4应用程序,我正在使用巫术进行身份验证,可以扫描授权..到目前为止,我可以登录,用户也可以这样做....我正在尝试添加activeadmin for管理仪表板我到目前为止设置了几乎所有内容,但是当我以管理员身份登录应用程序时启动链接http://localhost:3000/admin我得到错误:
未定义的方法`destroy_user_session_path' :ActiveAdmin ::浏览:: 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
有人能指出我如何解决这个问题......已经被困在这里一段时间......
欢呼答案 0 :(得分:0)
所以在进一步调查后,正确的方法是
config.logout_link_path =:user_session_path
但遗憾的是,ActiveAdmin目前还没有在登出路径上支持带有ID的网址。