【发布时间】:2019-02-12 12:10:35
【问题描述】:
您如何限制用户访问以使用户只能读取自己的记录?
我试过了:
def initialize(user)
can :read, User, :id => user.id
还有这个:
def initialize(user)
can :read, user
但我仍然可以访问索引和显示中的每个用户。我在 UsersController 中有 authorize_resource。
相关文档供参考: https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
【问题讨论】:
标签: ruby-on-rails authorization cancan cancancan