Hello! I''ve just started using ruby on rails, and I''d like for a first try create a simple website. But I can''t figure out how to organise it from the RoR point of view. Here is my problem: I''d like to set up a website with a two level menu, so there will be different groups of menu elements. Do I have to create one controller for each group? Each page would be then represented by one method. In that case then, how can I do to have one common layout for all the controllers? I got the fact that I shouldn''t repeat myself, but I think I read there is one layout for each controller. Then, if I want one global layout for the whole website, I would need to repeat the layout for each controller. I hope I made myself clear with my problem :/ If I''m completely wrong, please tell me! I feel RoR is really powerful, and I''d like to know how to deal with it! Thank you by advance! Best regards, Matthieu -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2007-Jan-22 23:15 UTC
Re: Which architecture to choose for a common website
> I''ve just started using ruby on rails, and I''d like for a first try > create a simple website. > > But I can''t figure out how to organise it from the RoR point of view. > > Here is my problem: > > I''d like to set up a website with a two level menu, so there will be > different groups of menu elements. > > Do I have to create one controller for each group? Each page would be > then represented by one method.You don''t have to, but it might be easier...> In that case then, how can I do to have one common layout for all the > controllers?app/controllers/application.rb: class ApplicationController < ActionController::Base layout ''default'' end app/controllers/about_controller.rb class AboutController < ApplicationController def index end def contact end .... end app/controllers/product_controller.rb class ProductController < ApplicationController def index end def product end .... end app/views/layouts/default.rhtml: <html> my default view... <%= yield "layout" %> ... </html>> > I got the fact that I shouldn''t repeat myself, but I think I read there > is one layout for each controller. Then, if I want one global layout for > the whole website, I would need to repeat the layout for each > controller. > > I hope I made myself clear with my problem :/ > > If I''m completely wrong, please tell me! I feel RoR is really powerful, > and I''d like to know how to deal with it! > > Thank you by advance! > > Best regards, > > Matthieu > > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/23/07, Matthieu <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello! > > I''ve just started using ruby on rails, and I''d like for a first try > create a simple website. > > But I can''t figure out how to organise it from the RoR point of view. > > Here is my problem: > > I''d like to set up a website with a two level menu, so there will be > different groups of menu elements. > > Do I have to create one controller for each group? Each page would be > then represented by one method.That''s not a bad way of organising things. Conceptually, one controller should be responsible for a closely related set of operations.> In that case then, how can I do to have one common layout for all the > controllers?in views/layouts, remove all the individual controller layouts and create an application.rhtml layout, which will be used as the default. Scaffolding will generate a layout for a new controller, so make sure you remove that if you don''t want it. --max --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you for both your answers! I see it clearlier now! I get back to work then! -- 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?hl=en -~----------~----~----~----~------~----~------~--~---