title: acl9 find just model object which satisfys object.accepts_role?(role_name, current_user)
body: <p>I'm pretty new to rails and it's the first time I'm actually using authlogic + acl9. I followed the default installation steps for both plugins.</p>
  
  <p>So far everything works great, but I have trouble to find an elegant solution for this problem:</p>
  
  <p>Let's say I have a model class called Products. When creating a new Product object I assign the current_user as the owner:</p>
  
  <pre><code>current_user.has_role! :owner, @product
  </code></pre>
  
  <p>I registered a second user and made sure that this part worked.</p>
  
  <p>In the products controller I have an index method, simply returning all products:</p>
  
  <pre><code>def index
    @products = Products.all
  end
  </code></pre>
  
  <p>My question is: How do I call the find method on Products in order to get just those products where the current_user is the :owner?
  So I using the acl9 interface that would mean:</p>
  
  <pre><code>@product.accepts_role?(:owner, current_user)
  </code></pre>
  
  <p>One possibility probably would be to first retrieve all products and then create a new array with just the current_user ones. so maybe like this:</p>
  
  <pre><code>@products = []
  products = Products.all
  products.each do |p|
    @products &lt;&lt; p if p.accepts_role?(:owner, current_user)
  end 
  </code></pre>
  
  <p>This solution seems pretty wasteful. So what's the right way to do it?</p>
  
  <p>Thanks everyone!</p>