0

我很难理解这句话的逻辑:

if (current_user.has_role? :admin, current_user.active_org)

4

2 回答 2

2

has_role?正在查看两个参数并返回一个布尔值。这大概是CanCan吧?如果是这样,它会说“当前用户是当前用户的活动 'org' 的管理员吗?”

Ability如果您想要更准确的答案,请发布您的课程。

于 2013-07-05T16:18:11.007 回答
1

基本上测试 admin 或 current_user.active_org 是否有效,基于是否设置了 has_role ......与:

if (current_user.has_role)
  if (admin)
    stuff...
  end
else
  if (current_user.active_org)
    same stuff...
  end
end

但只是更压缩。

于 2013-07-05T16:21:42.317 回答