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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Mar 24, 2009 at 1:03 PM, ressister <ressister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Mar 24, 2:09 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Mar 24, 2009 at 1:03 PM, ressister <ressis...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 Donaldhttp://destiney.com/--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---