I am trying to define an ability where a logged in participant can manage projects based on the invites.
Code below yields an error when I access a project undefined method project' for #<Project:0x007f2c998410>
can :manage, Project, :project=>{:invite=>{:participant=>{:user => {:id => user.id}}}}
TL;DR
The table relationships are below.
projects --> invites <-- participants <--users
我认为您在供应商模型中缺少has_manny :invites
关系
The hash format was incorrect. This works:
can :manage, Project, invites: {participant: {:user_id => user.id}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.