0

アプリケーションでロールを管理するために can-can gem を使用しました。

モデルは次のとおりです。

class User < ActiveRecord::Base  
  has_many :projects  
  has_and_belongs_to_many :teams  
end

class Project < ActiveRecord::Base  
  belongs_to :user  
  has_many :tasks  
end

class Tasks < ActiveRecord::Base  
  belongs_to :project  
end

class Ability  
  include CanCan::Ability  

  def initialize user  
    user ||= User.new  
    if user.team? :project_manger  
        can :access, :projects,:user_id => user.id  
    else  
        can :access, :all  
    end  
  end  
end

それで、私の質問は、ユーザーのプロジェクトに関連付けられているタスクをどのように管理できるかです。

4

0 に答える 0