Forum: Ruby on Rails separate controller for side-bar components?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ressister (Guest)
on 2009-03-24 20:04
(Received via mailing list)
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
Greg D. (Guest)
on 2009-03-24 20:10
(Received via mailing list)
On Tue, Mar 24, 2009 at 1:03 PM, ressister 
<removed_email_address@domain.invalid> 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/
ressister (Guest)
on 2009-03-24 21:11
(Received via mailing list)
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
This topic is locked and can not be replied to.