# \[Templates\] \[Noob\] templates across controllers?

**URL:** <https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270>\
**Category:** Rails\
**Created:** [December 28, 2005, 11:39pm UTC](https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270 "2005-12-28T23:39:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/u/DSAndrew_SDaveSS_Th)\
**Post date:** [December 28, 2005, 11:39pm UTC](https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270/1 "2005-12-28T23:39:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/u/DSAndrew_SDaveSS_Th)\
**Post date:** [December 28, 2005, 11:42pm UTC](https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270/2 "2005-12-28T23:42:38Z")

</div>

Dave,

Try a

app/views/layout/application.rhtml

Chris Nolan.ca  
[http://kekova.ca/](http://kekova.ca/)

---

<div class="post-metadata">

**Author:** ![DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/u/DSAndrew_SDaveSS_Th)\
**Post date:** [December 28, 2005, 11:51pm UTC](https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270/3 "2005-12-28T23:51:44Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@DSAndrew\_SDaveSS\_Th](https://www.ruby-forum.com/u/DSAndrew_SDaveSS_Th)\
**Post date:** [December 29, 2005, 1:40am UTC](https://www.ruby-forum.com/t/templates-noob-templates-across-controllers/51270/4 "2005-12-29T01:40:23Z")

</div>

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.
