宣言型承認に少し問題があります。has_and_belongs_to_manyアソシエーションを持つユーザーとロールモデルがあります。
Authorization_rules.rbに:moderatorという名前のロールを作成しました
ロールモデレーターを持つユーザーが、モデレーターロールが割り当てられているユーザーのみを取得することは可能ですか?-> User.with_permissions_to(:index)
私はそれがそのように可能であると思いました:
role :moderator do
has_permission_on :users, :to => :index do
if_attribute :roles => contains { ????? }
end
end
また、ユーザーモデルにnamed_scopeを作成したのは、それが役立つと思ったからです...
class User
has_and_belongs_to_many :roles
named_scope :by_role, lambda { |role|
{
:include => :roles,
:conditions => {"roles.name" => role}
}
}
end
declarative_authorizationでこれを行うことが可能かどうか誰かが知っていますか?
ご協力いただきありがとうございます!