title: Context aware authorization using CanCan
body: <p>I want to use CanCan to handle my permissions. My site has many different permissions levels, and most of them are context aware. For instance, Here are the relations in my 3 main models:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :league_relations
    has_many :leagues, :through =&gt; :league_relations
  end
  
  class League &lt; ActiveRecord::Base
    has_many :league_relations
    has_many :users, :through =&gt; :league_relations
  end
  
  class LeagueRelation &lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :league
  end
  </code></pre>
  
  <p>Note, LeagueRelations is a nested resource of Leagues. What I want to do is allow a user to modify leagues, and gauge each user's authorization based off of data stored in league_relation. I would then like a user to modify league relation, based only the data stored in the user model.</p>
  
  <p>To be succinct: I basically want LeagueRelations to be used to authorize League actions, and Users to be used to authorize LeagueRelations actions. i.e. league_relation.owner = true to delete a League, but user.owner? must be true to delete a LeagueRelation. How can I authorize based on the attributes of league_relation when inside the league controller, and authorize other actions in other controllers on other models. Please leave a comment if you need more clarification.</p>
  
  <p>Thanks.</p>