# When to make a new controller

**URL:** <https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223>\
**Category:** Rails\
**Created:** [May 1, 2006, 10:51pm UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223 "2006-05-01T22:51:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@Randal\_S](https://www.ruby-forum.com/u/Randal_S)\
**Post date:** [May 1, 2006, 10:51pm UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223/1 "2006-05-01T22:51:13Z")

</div>

Hey all,

Ok this is probably a newb question, but I haven’t been programming with  
MVC for very long, and I’ve been wondering what the general opinion is,  
or best practices, for making a new controller. Like what cases would  
you need a new controller for and what cases can you just put everything  
into one controller?

Thanks in advance,  
Randal

---

<div class="post-metadata">

**Author:** ![Randal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@Randal\_S](https://www.ruby-forum.com/u/Randal_S)\
**Post date:** [May 1, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223/2 "2006-05-01T22:57:46Z")

</div>

Randal,

It really depends on your preferences… I tend to design controllers  
around “units of functionality”. I find that if I have one controller  
juggling too many models, the code becomes cluttered…

For example, I could end up with a blogging controller that has list(),  
list\_articles() when it could be simply split up amongst 2 controllers:  
controller1.list(), controller2.list(). The added benefit is that it’s  
much easier to work with the scaffolding than to fight it… 🙂

Please be advised that I am not an expert in this area

ilan

Randal S. wrote:

> Hey all,
> 
> Ok this is probably a newb question, but I haven’t been programming with  
> MVC for very long, and I’ve been wondering what the general opinion is,  
> or best practices, for making a new controller. Like what cases would  
> you need a new controller for and what cases can you just put everything  
> into one controller?
> 
> Thanks in advance,  
> Randal

---

<div class="post-metadata">

**Author:** ![Randal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@Randal\_S](https://www.ruby-forum.com/u/Randal_S)\
**Post date:** [May 1, 2006, 10:58pm UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223/3 "2006-05-01T22:58:36Z")

</div>

If you’re just starting out, keep it simple and create a separate  
controller for each use case in your application.

Randal S. wrote:

> Hey all,
> 
> Ok this is probably a newb question, but I haven’t been programming with  
> MVC for very long, and I’ve been wondering what the general opinion is,  
> or best practices, for making a new controller. Like what cases would  
> you need a new controller for and what cases can you just put everything  
> into one controller?
> 
> Thanks in advance,  
> Randal

---

<div class="post-metadata">

**Author:** ![Randal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@Randal\_S](https://www.ruby-forum.com/u/Randal_S)\
**Post date:** [May 2, 2006, 3:54am UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223/4 "2006-05-02T03:54:41Z")

</div>

Thanks guys. I’ll keep that in mind!

Mick S. wrote:

> If you’re just starting out, keep it simple and create a separate  
> controller for each use case in your application.
> 
> Randal S. wrote:
> 
> > Hey all,
> > 
> > Ok this is probably a newb question, but I haven’t been programming with  
> > MVC for very long, and I’ve been wondering what the general opinion is,  
> > or best practices, for making a new controller. Like what cases would  
> > you need a new controller for and what cases can you just put everything  
> > into one controller?
> > 
> > Thanks in advance,  
> > Randal

---

<div class="post-metadata">

**Author:** ![Randal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@Randal\_S](https://www.ruby-forum.com/u/Randal_S)\
**Post date:** [May 3, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/when-to-make-a-new-controller/59223/5 "2006-05-03T18:58:40Z")

</div>

Be careful here… you don’t want to confuse controller’s with their  
actions. Controllers are a way to group user-focused functionality,  
but unless you are designing extremely broad use cases, each of your  
apps controllers will likely impact far more than a single use case.

Since people like to use the “blog app” example, I would recommend  
downloading the Typo source code and looking at how the Controllers  
and Models are laid out in there. It’s a pretty good balance, with  
probably a few more controllers than is actually needed (not counting  
the admin stuff, since admin interfaces are very different from user  
interfaces), but still a very good organization example.

-Brian
