以下が条件です
私は1 に属し、同様users
に 1に属します。work
category
work
今、私はその特定の作品のユーザーを、その作品にedit
属するカテゴリーに入れたいと思っています。
ability
これをモデルで指定するにはどうすればよいですか?
編集 :
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
user.roles.each do |role|
role.name
if role.name == "admin"
can :read, User
can :create, User
can :edit, User
can :destroy, User
end
if role.name == "staff"
can :read, :all
can :create, :all
cannot :edit, Category
can :update, :all
can :destroy, :all
end
if role.name == "others"
can :read, :all
end
end
end
end