# How to implement a global partial?

**URL:** <https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384>\
**Category:** Rails\
**Created:** [May 12, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384 "2006-05-12T22:57:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [May 12, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384/1 "2006-05-12T22:57:02Z")

</div>

Quick question:

Whats the easiest way to implement a global partial? Where I can call  
one partial from many different controllers (err controller views)?

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [May 12, 2006, 11:01pm UTC](https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384/2 "2006-05-12T23:01:18Z")

</div>

IIRC, you can simply prefix the partial name with a path and it will  
work.

ex:

```
render :partial => "partials/myglobalpartial"

```

will render app/views/partials/\_myglobalpartial.rhtml

Is that what you were looking for?

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [May 13, 2006, 12:36am UTC](https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384/3 "2006-05-13T00:36:55Z")

</div>

Why not put it in the layouts directory? You could just have  
/layouts/\_mypartial.rhtml and call like render :partial =\>  
“layouts/mypartial”

I haven’t tried it, so I can’t verify if it works or not, but I’d much  
rather keep items that are global in the layouts directory where my  
layout  
is stored. Of course, I am assuming that you are using a layout… which  
would be best if you are using the same base markup for all of your  
pages.

HTH,  
Ryan

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [May 13, 2006, 12:39am UTC](https://www.ruby-forum.com/t/how-to-implement-a-global-partial/60384/4 "2006-05-13T00:39:27Z")

</div>

Excellent, that was exactly what I was looking for. Thanks guys.
