开发者

cancan is not calling the ability method

I want to limit 开发者_运维知识库the access to read the lead for a user. I have the relation as : Account has many office and Account also has users. And Office has leads. Now only the user associated with the office can view its lead.

I have defined the ability as :

 can :read, Lead do |lead, office|
      @office && user.account_ids.include?(@office.account_id)
 end

And I have this in the view :

- if can? :read, Lead, @office

but I can see that the above ability check is not being called with the view mentioned. Am I messing something here ?


The code should read something like this:

can :read, Office do |office|
  office && user.account_ids.include?(office.account_id)
end

View:

- if can? :read, @office
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜