# Listing documents in two different controllers - refactor?

**URL:** <https://www.ruby-forum.com/t/listing-documents-in-two-different-controllers-refactor/121120>\
**Category:** Rails\
**Created:** [November 24, 2007, 1:43am UTC](https://www.ruby-forum.com/t/listing-documents-in-two-different-controllers-refactor/121120 "2007-11-24T01:43:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [November 24, 2007, 1:43am UTC](https://www.ruby-forum.com/t/listing-documents-in-two-different-controllers-refactor/121120/1 "2007-11-24T01:43:57Z")

</div>

Hello,

if I have a document model (not RESTful) that belongs\_to  
document\_category and a document controller with a list action, and I  
want to list document per category  
can I just pass the id of the category as the :id GET param of the  
list action and filter the documents for this category?

I think that that this wouldn’t be semantically good since one would  
expect to get a list of all documents in the list action. The correct  
way I think would be to get the filtered documents by category in the  
document\_categories/show/2. Also, document\_categories/list would show  
a list of document categories and not documents, right?

The point here is that I think that this is not dry since I have two  
actions in two different controllers that lits documents - one all and  
the other filtered. Of course I could have some kind of shared partial  
for each document entry but the code in the controllers would still be  
similar.

This smells refactoring somehow…

Any suggestions on best practices regarding this?

Thanks in advance!

Marcelo.
