title: Getting an average count based on parameters from both the parent and child model
body: <p>If a <code>User</code> <code>has_many</code> <code>Items</code>. And items can be published by setting the <code>:published</code> attribute in items to <code>true</code>.</p>
  
  <p>How do I get the <strong>average number</strong> of <strong>published items</strong>, <strong>per user</strong> that <strong>created</strong> an item?</p>
  
  <p>I have a scope for items called <code>published</code>, so you can get all published items by writing:</p>
  
  <pre><code>@items = Item.published
  @items = @user.items.published
  </code></pre>