我正在寻找一种方法来检查用户是否从模型中登录到 activeadmin。除非用户登录,否则应拒绝访问特定属性。我希望有这样的东西,但找不到让它工作的方法:
class Object < ActiveRecord::Base
def should_show?
# find activeadmin user
if ActiveAdmin.current_admin_user?
# activeadmin user is logged in
true
else
# not logged in
false
end
end
end