title: Rails declarative_authorization project_admin role
body: <p>I am trying to create project admin and project collaborator roles using the <a href="https://github.com/stffn/declarative_authorization" rel="nofollow">declarative_authorization</a> gem.</p>
  
  <p>I have a table called 'collaborators' which holds the users to projects mappings.</p>
  
  <p>Models:</p>
  
  <p>Project  </p>
  
  <pre><code>has_many :collaborators  
  has_many :users, :through =&gt; :collaborators  
  </code></pre>
  
  <p>User</p>
  
  <pre><code>has_many :collaborators
  has_many :projects, :through =&gt; :collaborators
  </code></pre>
  
  <p>Collaborator</p>
  
  <pre><code>belongs_to :user
  belongs_to :project
  </code></pre>
  
  <p>I need some guidance on defining the dsl for project_admin and project_collaborator role.
  I have come up with the following:</p>
  
  <pre><code>authorization do
    role :guest do
      has_permission_on :users, :to =&gt; [:read]
    end
  
    role :project_admin do
      has_permission_on :projects, :to =&gt; :manage do
        if_attribute :project_admin =&gt; true
      end
    end
  
    role :admin do
      has_permission_on :users, :to =&gt; [:delete]
    end
  end
  
  privileges do
    privilege :manage do
      includes :create, :read, :update, :delete
    end
  end
  </code></pre>
  
  <p>Appreciate any suggestions/help.<br>
  Thanks!</p>