Fine Rails Hackers: I am trying to decide how to approach a templating concern. I would like to define a standard template for all of my pages (including a basic header, styles, footer) across my five base controllers: desktop, events, financials, and records, account. Is there a top level place to declare a template across the entire application regardless of the controller? I understand how to declare a template within a controller, say desktop (in app/views/layouts/desktop.rhtml). But how do I define something that can serve as a template for all of the controllers? I don't want to reproduce the template for each controller (in the layout folder). Thank you, Dave
on 2005-12-29 00:39
on 2005-12-29 00:42
Dave, Try a app/views/layout/application.rhtml Chris Nolan.ca http://kekova.ca/
on 2005-12-29 00:51
i think the best way to do this would be to have all your pages use the same layout, and include the style-sheet, header and footer info in there. This should be easy to do, if u have a layout called application (and no other layout files) your app will use this across all pages. Alternatively you can declare the layout using the layout method (see rails api for more information on that).
on 2005-12-29 02:40
Worked like a charm. I just found in the book where it notes the use of "application" for applying layouts to all controllers. Of note, I had to remove the other controller-named layouts in the same folder, which is the first place Rails goes. Thanks.