# Question about "partial controllers" sub-applicaktions

**URL:** <https://www.ruby-forum.com/t/question-about-partial-controllers-sub-applicaktions/156278>\
**Category:** Rails\
**Created:** [December 23, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/question-about-partial-controllers-sub-applicaktions/156278 "2008-12-23T20:48:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![html-kurs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@html-kurs](https://www.ruby-forum.com/u/html-kurs)\
**Post date:** [December 23, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/question-about-partial-controllers-sub-applicaktions/156278/1 "2008-12-23T20:48:52Z")

</div>

Hello,

I’ve got two questions about best practices using Ruby on Rails:

First, think about a website which has several relative independant  
parts: Some news, some dates of fairs, some jobs and so on.  
Using the “RoR-filesystem layout” there’s one folder app/models with all  
the models used in these different parts. Another folder app/controllers  
containing the different controllers and so on.  
Now think about another website on another server which should consist  
of similar parts but not of all of them.  
So if I want to reuse some parts I have to sort out the parts I need.  
That could be tricky. So is there a way to use subfolders in the  
following way:  
appnews/controllers  
/models  
/views  
appdates/controllers  
/models  
/views  
appjobs/controllers  
/models  
/views  
and so on?  
What’s “the rails way” to do it?

My second question is about “partial controllers”: Think of the above  
website. I want to use a (rails-) layout to present all parts in the  
same way. Maybe to columns. The main column should contain the main  
content of the sub-application (e.g. the latest news). And the second  
column should contain content of the other parts (e.g. the latest date  
of fairs). Fetching the stuff out of the database (using the different  
models) would be part of all controllers. So I’d like to use  
“partial-controllers” in a way we use partial views. So I have only to  
write the code once and include it from each controller.  
So what’s the best way to do it in rails?

Thanks,  
Martin

---

<div class="post-metadata">

**Author:** ![html-kurs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@html-kurs](https://www.ruby-forum.com/u/html-kurs)\
**Post date:** [December 23, 2008, 8:56pm UTC](https://www.ruby-forum.com/t/question-about-partial-controllers-sub-applicaktions/156278/2 "2008-12-23T20:56:29Z")

</div>

I’ll be watching the answers to this thread myself, as I’m curious what  
the  
experts will reply. But I (a newbie) suspect one answer may be to write  
plugins for those portions of the code that you anticipate will be  
reusable.

Of course I haven’t the foggiest idea how one starts off writing code in  
a  
style suitable for being made into a plugin. But perhaps you and your  
friend Google and start investigating that path while you await answers  
from  
folks who actually do this sort of thing for a living.

–wpd

---

<div class="post-metadata">

**Author:** ![html-kurs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@html-kurs](https://www.ruby-forum.com/u/html-kurs)\
**Post date:** [December 29, 2008, 1:44pm UTC](https://www.ruby-forum.com/t/question-about-partial-controllers-sub-applicaktions/156278/3 "2008-12-29T13:44:44Z")

</div>

[http://m.onkey.org/2007/12/9/namespaced-models](http://m.onkey.org/2007/12/9/namespaced-models) seems to be talking  
about same problems. You might wanna read it.
