I have a site with a complex database and about 10 models. The main page of the site has around 5 tables/models bringing data in, so conceptually it seems like I should use a controller on each model. Is there a way to render multiple controllers on a page or am I going about this the wrong way. I''d like to keep the size of my controllers down so writing the entire application in one controller seems like a bad solution. Can anyone suggest anything? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It can appear that way at first. One of the really good sessions at RailsConf reminded us to keep the controllers thin. Put all your business logic in the models. The controllers are really just intended to assemble data from the models for presentation by the views. So, controllers are more related to views than to models. They assemble the data and the view formats it and gives the user a way to poke it. The controller than does something as a result of the poke by the user, and it all starts over. Having only one controller for a one page application sounds just fine. But, all it should do is fetch a few records and possibly traverse a few associations, then hand off to the view. Michael On Jun 26, 2007, at 7:26 PM, Jables wrote:> > I have a site with a complex database and about 10 models. The main > page of the site has around 5 tables/models bringing data in, so > conceptually it seems like I should use a controller on each model. > Is there a way to render multiple controllers on a page or am I going > about this the wrong way. I''d like to keep the size of my controllers > down so writing the entire application in one controller seems like a > bad solution. Can anyone suggest anything? > > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- >
I''m also trying to find the correct way to structure a rails application. Michael''s advice is the first that I''ve seen that addresses this. Can I ask if anyone knows of any resources that cover the correct way to architect a rails application? Everything I''ve found so far describes the correct syntax of the code rather than how to structure the code. I guess I''m looking for something that covers rails design patterns. Thanks to anyone who can help with this. David Michael Latta <lattam-ee4meeAH724@public.gmane.org> wrote: It can appear that way at first. One of the really good sessions at RailsConf reminded us to keep the controllers thin. Put all your business logic in the models. The controllers are really just intended to assemble data from the models for presentation by the views. So, controllers are more related to views than to models. They assemble the data and the view formats it and gives the user a way to poke it. The controller than does something as a result of the poke by the user, and it all starts over. Having only one controller for a one page application sounds just fine. But, all it should do is fetch a few records and possibly traverse a few associations, then hand off to the view. Michael On Jun 26, 2007, at 7:26 PM, Jables wrote:> > I have a site with a complex database and about 10 models. The main > page of the site has around 5 tables/models bringing data in, so > conceptually it seems like I should use a controller on each model. > Is there a way to render multiple controllers on a page or am I going > about this the wrong way. I''d like to keep the size of my controllers > down so writing the entire application in one controller seems like a > bad solution. Can anyone suggest anything? > > > >--------------------------------- Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!''s user panel and lay it on us. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
i have an app similar to the one you described. I have about 8 models that have to be referenced for the main page of our site. The way i do it is with a lot of partials, that way, the piece of page that i am rendering on the main page always more or less from a controller associated with what i want to display, and, as listed above, i try to keep most of my real logic in the models. Don''t know if this setup is ideal, but it does make things easier to find sitewide. shawn On Jun 27, 5:19 am, David Garton <d...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I''m also trying to find the correct way to structure a rails application. Michael''s advice is the first that I''ve seen that addresses this. Can I ask if anyone knows of any resources that cover the correct way to architect a rails application? Everything I''ve found so far describes the correct syntax of the code rather than how to structure the code. I guess I''m looking for something that covers rails design patterns. > > Thanks to anyone who can help with this. > David > > Michael Latta <lat...-ee4meeAH724@public.gmane.org> wrote: > > It can appear that way at first. One of the really good sessions at > RailsConf reminded us to keep the controllers thin. > > Put all your business logic in the models. The controllers are > really just intended to assemble data from the models for > presentation by the views. So, controllers are more related to views > than to models. They assemble the data and the view formats it and > gives the user a way to poke it. The controller than does something > as a result of the poke by the user, and it all starts over. > > Having only one controller for a one page application sounds just > fine. But, all it should do is fetch a few records and possibly > traverse a few associations, then hand off to the view. > > Michael > > On Jun 26, 2007, at 7:26 PM, Jables wrote: > > > > > I have a site with a complex database and about 10 models. The main > > page of the site has around 5 tables/models bringing data in, so > > conceptually it seems like I should use a controller on each model. > > Is there a way to render multiple controllers on a page or am I going > > about this the wrong way. I''d like to keep the size of my controllers > > down so writing the entire application in one controller seems like a > > bad solution. Can anyone suggest anything? > > --------------------------------- > Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!''s user panel and lay it on us.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---