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