Hi there, I want to have a default index page which just uses the layout (from layout/application.html.erb) - however the default index page in public does not seem to use the layouts, it doesnt need to call any controller at this point just display the default layout, how can I achieve this? Thanks -- Posted via http://www.ruby-forum.com/.
Hi Pete, On Fri, 2009-08-14 at 19:15 +0200, Pete Moran wrote:> Hi there, > > I want to have a default index page which just uses the layout (from > layout/application.html.erb) - however the default index page in public > does not seem to use the layouts, it doesnt need to call any controller > at this point just display the default layout, how can I achieve this?You have to get rid of public/index.html. All pages delivered by Rails result from calls to controller methods. If all you want is to render the default layout, then just define an empty view that gets rendered via an empty controller method and either call the method explicitly or make it your default with map.root. HTH, Bill
bill walton wrote:> Hi Pete, > > On Fri, 2009-08-14 at 19:15 +0200, Pete Moran wrote: >> Hi there, >> >> I want to have a default index page which just uses the layout (from >> layout/application.html.erb) - however the default index page in public >> does not seem to use the layouts, it doesnt need to call any controller >> at this point just display the default layout, how can I achieve this? > > You have to get rid of public/index.html. All pages delivered by Rails > result from calls to controller methods. If all you want is to render > the default layout, then just define an empty view that gets rendered > via an empty controller method and either call the method explicitly or > make it your default with map.root. > > HTH, > BillThanks Bill, So I should just set a empty view in one of my controllers, or should I create a dummy controller just for this index page? Pete -- Posted via http://www.ruby-forum.com/.
On Fri, 2009-08-14 at 19:34 +0200, Pete Moran wrote:> Thanks Bill,You''re welcome.> So I should just set a empty view in one of my controllers, or should I > create a dummy controller just for this index page?After thinking about your earlier post a bit more though I''d say you may want to think this thing through a bit more. A layout contains the base html for the site''s pages including the <head> section and components of the <body> section that are common to all the pages that will use that layout. Headers, footers, navigation, etc. Each ''page'' delivers its content into the <%= yield %> in the layout. If all the rest of the site''s pages will display everything that''s on the index page, then either of the approaches you mention would work and it''s just a judgment call. That would be a pretty unusual index page, though. At least in my experience. Best regards, Bill
Well in this case its the start of a admin section of a site, where firstly it just displays the left nav and the main content is blank. Perhaps in the future the main content won''t be blank but for now thats how it is. Its also makes me think about how controllers should work in this case, as this is effectively a home page and doesn''t use any of the other controllers until a option has been selected from the nav - so using a blank def from one of the other controllers seems a bit odd. I was thinking perhaps there should be a ''home'' controller and home model, which at the moment the home model did nothing, but perhaps did something later... Thanks again for your help! Pete -- Posted via http://www.ruby-forum.com/.