Separate controller for side-bar components?

I’m in the process of refactoring an existing Rails app and am
wondering - is it common practice to have a controller for each model
that has CRUD actions? For instance, in my app I have a side bar
where users can add diary entries to a side-bar, highlighting them in
bulletin-board fashion within their diary. This bulletin board will
only live inside the diary. Should it have its own controller then?

What’s the general rule. I’ve been reading The Rails Way, and it
seems that it should, which would also allow me to create a nested
resource for this as well which would allow for some out-of-the-box
routing if I were ever to surface this component somewhere else.

I look forward to your thoughts, and thanks!

-A

On Tue, Mar 24, 2009 at 1:03 PM, ressister [email protected] wrote:

I’m in the process of refactoring an existing Rails app and am
wondering - is it common practice to have a controller for each model
that has CRUD actions? For instance, in my app I have a side bar
where users can add diary entries to a side-bar, highlighting them in
bulletin-board fashion within their diary. This bulletin board will
only live inside the diary. Should it have its own controller then?

It’s up to you how to separate things, there’s no limit on how many or
how few controllers you can or have to have.

What’s the general rule. I’ve been reading The Rails Way, and it
seems that it should, which would also allow me to create a nested
resource for this as well which would allow for some out-of-the-box
routing if I were ever to surface this component somewhere else.

I look forward to your thoughts, and thanks!

I split things up as much as I can at the start, makes growing the app
easier later. You might consider putting things that require
authentication in separate controllers than one that don’t for
example.


Greg D.
http://destiney.com/

Thanks for the response Donald. I started in just the opposite
direction - with only a couple core controllers. I wasn’t sure if it
was common to have a controller for each model in your app? Perhaps
that’s the guiding principle, and you make judgements based on that.

I like your suggestion of splitting based on Authenticated versus
public. I’m already doing that for the most part, so perhaps I will
add a few more controllers for authenticated models/views to make the
app more CRUD compliant.

Let me know if you have any other thoughts and thanks again for your
response.

-A