如何获取通过活动管理员登录的当前用户? [英] How to get the current user that is logged in via active admin?
本文介绍了如何获取通过活动管理员登录的当前用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何获取通过活动管理GUI登录的当前用户?
I would like to know how to get the current user that is logged in via the active admin GUI?
首页:http://www.activeadmin.info/
预先感谢
模型
admin_user.rb
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :id , :admin_permission
# attr_accessible :title, :body
has_one :admin_permission
validates_uniqueness_of :email
def self.current_logged_user
# ?
end
end
更新
当我尝试在dashboard.rb或任何与管理相关的活动文件中使用方法 current_user时,显然未实现。
When I try to use the method 'current_user' in dashboard.rb or any active admin related file, apparently it is not implemented.
输出
undefined local variable or method `current_user' for
推荐答案
默认情况下称为 AdminUser
。因此,相应的设计助手方法是 current_admin_user
。
The active admin user is called AdminUser
by default. The corresponding devise helper method is therefore current_admin_user
.
这篇关于如何获取通过活动管理员登录的当前用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文