我有个坎坎授权问题。
我的情况是这样的。
User has_one Student在StudentsController中,我有这样的用户和学生
@user = User.where(:username => params[:username]).first
@student = @user.student现在,我如何编写cancan授权规则来编辑/更新@学生记录,以便日志用户只能编辑其学生记录,条件是@ user 可能是登录用户,也可能不是登录用户。它只是用户名形式为params的用户。
我希望问题清楚:)
谢谢
发布于 2013-02-07 03:57:53
查看wiki中的CanCan:
https://github.com/ryanb/cancan/wiki/Defining-Abilities
通过执行以下操作,您应该能够在能力模型中定义该能力:
can :edit, Student, :user_id => user.idhttps://stackoverflow.com/questions/14743132
复制相似问题