if_attribute syntax problem on declarative_authorization

泪湿孤枕 提交于 2019-12-08 12:18:26

问题


I have an Organization that has_many Affiliations And a mission that has_one Organization

So i can do this:

m = Mission.first
m.organization.affiliations 

A user also has_many affiliations so I can do:

u = User.first
u.affiliations

In declarative_authorization I want a user to be able to manage a mission if he is affiliated to the organization of the mission.

I'm trying this:

has_permission_on :missions, :to => [:manage] do
  if_attribute [:affiliations, {:mission => :organization} ]  => intersects_with {
    user.affiliations.type_admin
  }
end

But I get the error:

[:affiliations, {:mission=>:organization}] is not a symbol

What's wrong with the syntax?


回答1:


I think this might work for you

has_permission_on :missions, :to => [:manage] do
  if_attribute :organization => { :affiliations => intersects_with { user.affiliates.type_admin } }
end


来源:https://stackoverflow.com/questions/2547352/if-attribute-syntax-problem-on-declarative-authorization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!