# Generating one page with multiple controllers

**URL:** <https://www.ruby-forum.com/t/generating-one-page-with-multiple-controllers/182489>\
**Category:** Rails\
**Created:** [January 28, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/generating-one-page-with-multiple-controllers/182489 "2010-01-28T21:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapsel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/71e660/32.png) [@kapsel](https://www.ruby-forum.com/u/kapsel)\
**Post date:** [January 28, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/generating-one-page-with-multiple-controllers/182489/1 "2010-01-28T21:43:05Z")

</div>

Hi,

So I have an application in rails. The purpose of the application is to  
display test results written to the database. Each test consists of  
several defined operations. Each operation can have multiple sub  
operations (witch results in a tree like structure). Some of the defined  
operations have to be displayed in a uniq way and some have a default  
view. Also Most of the tests have some uniq summary.  
So the main way to display the test is to display the operations that  
where used in it. In a first view only the root operations are  
displayed. And if a user is interested in the operation he can click on  
it expanding it.  
So my current version of the application reads the root operations  
associated with a test. Based on a operation definition there is a big  
case statement witch is used to map operation to a specific shared view.  
This is done via partial renders witch update parts of the page via  
ajax. So on one html page I have different parts of it (operations)  
controlled by different view’s (but not controllers â€“ there is only one  
controller). The logic to each operation is added via helpers.

So this actual works but… I don’t like the solution because all the  
application logic is located in helpers and shared partial view’s. As I  
understand rails concept is to put the application logic into  
controllers. But I don’t know how to use multiple controllers to create  
one page (each controller has to have control of a part of a page). I’m  
looking for a way to design the application in a more scalable way  
because my solution is a little messy… ;).  
Any ideas would be appreciated.

---

<div class="post-metadata">

**Author:** ![kapsel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/71e660/32.png) [@kapsel](https://www.ruby-forum.com/u/kapsel)\
**Post date:** [January 29, 2010, 10:01am UTC](https://www.ruby-forum.com/t/generating-one-page-with-multiple-controllers/182489/2 "2010-01-29T10:01:51Z")

</div>

You can use MVC paradigm to your application interface, too. As you  
describe it, It sounds that is the client side which must handle the  
logic; well, design it using MVC. This article from A List Apart may  
be useful:

> **[JavaScript MVC](https://alistapart.com/article/javascript-mvc/)**
>
> As JavaScript takes center stage in our web applications, we need to produce ever more modular code. MVC (Model-View-Controller) may hold the key. MVC is a design pattern that breaks an application…

---

<div class="post-metadata">

**Author:** ![kapsel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/71e660/32.png) [@kapsel](https://www.ruby-forum.com/u/kapsel)\
**Post date:** [January 29, 2010, 2:18pm UTC](https://www.ruby-forum.com/t/generating-one-page-with-multiple-controllers/182489/3 "2010-01-29T14:18:29Z")

</div>

Grzegorz Lysko wrote:  
[…]

> As I  
> understand rails concept is to put the application logic into  
> controllers.

Not really. Most of the logic should go in the models.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
