Hello all, I''m working on developing a rather large and complex rails application. The interface will resemble something like a MDI interface with 3 "frames" statically located in the browser window. Each of the frames will have (2-5, fluctuating) tabs that allow for the display of different information. I''ve got a significant chunk of it coded and working, but I''m afraid I''ve coded myself into a corner and am preparing for a possible refactor of the app''s design (code, not interface). It seemed to me, when I started, that it made sense for me to create a controller for what amounts to each tab. That would give me clean code seperation and keep everything managable. However, I think in retrospect that I may have toasted my domain model by taking this approach. I''ve also considered creating a controller for each frame which would give me 3 controllers, still broken out logically and fairly clean. . .but I don''t think this really solves my problem. So, here I am thinking at this point that maybe a single controller is probably the "correct" way to go with this app. There is only one layout and is not nor will there be multiple pages (it''s all one page that runs %100 AJAX). The original problem and reason I''m thinking 1 controller is the way to go is that currently my "application.rhtml" layout just defines an application window, then my main controller''s index.rhtml fills in with the (div) definition of the 3 frames which contain render :partials to populate the actual data for each frame. There''s obviously a problem when I have to either "southern engineer" or use render_component to get the stuff from other controllers to render. With the above being the case, it seems to me as though the "rails way" is pushing me towards one controller. . but that gets pretty messy from a code perspective. So, there''s my situation. I''m humbly asking for advice from some of you guys that have worked on more complex applications as to the best way to approach this, or have I missed some other option somewhere? I''ve just gone back and read the Agile Rails chapters on the Controllers and ActionViews hoping to get some jewel of wisdom, but it''s focused on examples that are too trivial to help me out (understandably). Any advice greatly appreciated. If I need to provide more info, let me know. H -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
How many lines of code so far? A controller for each model isn''t necessarily a bad thing, and a One True Controller mightn''t sound too bad until your app has to do more stuff. Unless you are having problems right now, I would just finish it and refactor at the end. Refactoring and redesign is always more obvious with a complete app than an incomplete one. On 8/24/06, Hardy <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello all, > > I''m working on developing a rather large and complex rails > application. The interface will resemble something like a MDI interface > with 3 "frames" statically located in the browser window. Each of the > frames will have (2-5, fluctuating) tabs that allow for the display of > different information. > > I''ve got a significant chunk of it coded and working, but I''m afraid > I''ve coded myself into a corner and am preparing for a possible refactor > of the app''s design (code, not interface). It seemed to me, when I > started, that it made sense for me to create a controller for what > amounts to each tab. That would give me clean code seperation and keep > everything managable. However, I think in retrospect that I may have > toasted my domain model by taking this approach. > > I''ve also considered creating a controller for each frame which would > give me 3 controllers, still broken out logically and fairly clean. . > .but I don''t think this really solves my problem. > > So, here I am thinking at this point that maybe a single controller is > probably the "correct" way to go with this app. There is only one > layout and is not nor will there be multiple pages (it''s all one page > that runs %100 AJAX). The original problem and reason I''m thinking 1 > controller is the way to go is that currently my "application.rhtml" > layout just defines an application window, then my main controller''s > index.rhtml fills in with the (div) definition of the 3 frames which > contain render :partials to populate the actual data for each frame. > There''s obviously a problem when I have to either "southern engineer" or > use render_component to get the stuff from other controllers to render. > > With the above being the case, it seems to me as though the "rails > way" is pushing me towards one controller. . but that gets pretty messy > from a code perspective. > > So, there''s my situation. I''m humbly asking for advice from some of > you guys that have worked on more complex applications as to the best > way to approach this, or have I missed some other option somewhere? > I''ve just gone back and read the Agile Rails chapters on the Controllers > and ActionViews hoping to get some jewel of wisdom, but it''s focused on > examples that are too trivial to help me out (understandably). > > Any advice greatly appreciated. If I need to provide more info, let me > know. > > H > > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Richard Conroy wrote:> How many lines of code so far? A controller for each model isn''t > necessarily a bad thing, and a One True Controller mightn''t sound > too bad until your app has to do more stuff. > > Unless you are having problems right now, I would just finish it > and refactor at the end. Refactoring and redesign is always more > obvious with a complete app than an incomplete one.Richard, I''m only about 20% of the way through the entire app, but like I said, it''s a signficant app. The tabs aren''t tied to models, they just provide different functionality. For instance, the frame on the left provides a list, click on an entry and it provides more detail in the upper right frame, click on something there and you get most detailed view in bottom right frame. Maybe I should just keep plugging away. You are right about getting the 10,000 ft view when you''re done. Just wish I could figure out what the "right" way is for such a non-trivial app. Thanks!! H -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hardy wrote:> Richard Conroy wrote: > > How many lines of code so far? A controller for each model isn''t > > necessarily a bad thing, and a One True Controller mightn''t sound > > too bad until your app has to do more stuff. > > > > Unless you are having problems right now, I would just finish it > > and refactor at the end. Refactoring and redesign is always more > > obvious with a complete app than an incomplete one. > > > Richard, > > I''m only about 20% of the way through the entire app, but like I said, > it''s a signficant app. The tabs aren''t tied to models, they just > provide different functionality. For instance, the frame on the left > provides a list, click on an entry and it provides more detail in the > upper right frame, click on something there and you get most detailed > view in bottom right frame. > > Maybe I should just keep plugging away. You are right about getting > the 10,000 ft view when you''re done. Just wish I could figure out what > the "right" way is for such a non-trivial app. > > Thanks!! > > H > > > -- > Posted via http://www.ruby-forum.com/.I agree with Richard. I just finished building an app like what you''re saying. It has one main page, and a few div''s that have a few tabs which refresh just that div. I had about 7 controllers, however that was because I had around 7 models, so it made sense. It''s nice to have a controller for every model, but if you only have 1 model (or none) then try going with just 1 controller. Richard is definitely right about refactoring when you''re done... I wasted a lot of time when I was doing my app and refactoring in the middle of it. Good luck, let us know how it goes. -Ben Lisbakken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---