title: Filter index in activeAdmin
body: <p>In my activeadmin application, I need to filter the records that will appear in the index view.</p>
  
  <p>For my "Group" model, the collection approach works well but for the "Item" model, it does not work and return the following error:</p>
  
  <pre><code>undefined method `page' for #&lt;Array:0xc240bc4&gt;
  </code></pre>
  
  <p>I use this code in admin/items.rb: => does not work</p>
  
  <pre><code>collection_action :index, :method =&gt; :get do
    # Only get the items belonging to a group owned by the current user
    scope = Group.where("owner_id = ?", current_user.id).map{|group| group.items}
  
    @collection = scope.page() if params[:q].blank?
    @search = scope.metasearch(clean_search_params(params[:q]))
  
    respond_to do |format|
    format.html {
      render "active_admin/resource/index"
    }
    end
  end
  </code></pre>
  
  <p>In admin/groups.rb, the following works fine though (only the correct groups are displayed)</p>
  
  <pre><code>collection_action :index, :method =&gt; :get do
    # Only get the groups owned by the current user
    scope = Group.where("owner_id = ?", current_user.id).scoped
  
    @collection = scope.page() if params[:q].blank?
    @search = scope.metasearch(clean_search_params(params[:q]))
  
    respond_to do |format|
      format.html {
        render "active_admin/resource/index"
      }
    end
  end
  </code></pre>
  
  <p>I cannot figure out why this is not working for the "Item" model. Any idea ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I find a workaround, only getting the items of the first groups belonging to the current_user:</p>
  
  <pre><code>scope = Group.where("owner_id = ?", current_user.id).first.items.scoped
  </code></pre>
  
  <p>It's ok for now because the users only have one group but this will not be suitable in a near future.</p>