title: Complex conditions in CanCanCan can method
body: <p>If I have user,client and request models as follows:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#user.rb
  
  
  #client.rb
  has_one :user
  has_many :requests
  
  #request.rb
  belongs_to :client</code></pre>
  </div>
  </div>
  </p>
  
  <p>I use user model for CanCanCan authentication.
  Inside ability class i want to specify ability for client. I want to user to allow read,update only for requests that belong to him.
  Her is what i try:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>def client
    can [:read,:update], [Request], ['client_id = ?', user.client_id] do |client|
        ......something here
    end
  end</code></pre>
  </div>
  </div>
  </p>