# Best way to use partial rendering in global layout

**URL:** <https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535>\
**Category:** Rails\
**Created:** [March 14, 2006, 1:00am UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535 "2006-03-14T01:00:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 1:00am UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/1 "2006-03-14T01:00:59Z")

</div>

I have a global layout in application.rhtml and I’d like to render a  
partial template within it.

Currently, I have this:

\<%= render (:partial =\> ‘side\_nav’) %\>

but it seems to be looking in the controller specific view directory.

What is the best way to do handle controller - global partial rendering?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 1:08am UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/2 "2006-03-14T01:08:10Z")

</div>

ANSWER:  
Create a “shared” directory under app/views and do:

\<%= render ( :partial =\> ‘shared/side\_nav’ ) %\>

THANKS DAVE THOMAS!

Wes

Wes G. wrote:

> I have a global layout in application.rhtml and I’d like to render a  
> partial template within it.
> 
> Currently, I have this:
> 
> \<%= render (:partial =\> ‘side\_nav’) %\>
> 
> but it seems to be looking in the controller specific view directory.
> 
> What is the best way to do handle controller - global partial rendering?
> 
> Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 11:07am UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/3 "2006-03-14T11:07:12Z")

</div>

What if you want to use a global partial most of the time, but sometimes  
want  
to override it?

## Would it add any value to have rails check the controller specific directory first, and then automatically look in shared/global/layouts/whatever if not found? Seems intuitive to me, but may just mean higher complexity with no real gain.

View this message in context:  
[http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886](http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/4 "2006-03-14T16:53:48Z")

</div>

I think that’s how it works now, actually.

I scaffolded a new controller and the default layout that was generated  
got used until I removed it, and then the global one got used.

Wes

Lucifron wrote:

> What if you want to use a global partial most of the time, but sometimes  
> want  
> to override it?
> 
> ## Would it add any value to have rails check the controller specific directory first, and then automatically look in shared/global/layouts/whatever if not found? Seems intuitive to me, but may just mean higher complexity with no real gain.
> 
> View this message in context:  
> [http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886](http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886)  
> Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/5 "2006-03-14T19:06:43Z")

</div>

Wes G. wrote:

> I think that’s how it works now, actually.
> 
> I scaffolded a new controller and the default layout that was generated  
> got used until I removed it, and then the global one got used.
> 
> Wes  
> Layouts work this way, yes, but not partials.

–  
View this message in context:  
[http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727](http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 14, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/best-way-to-use-partial-rendering-in-global-layout/81535/6 "2006-03-14T19:12:56Z")

</div>

That’s right.

I don’t know - I think someone would find a good use for that feature  
with partials.

Wes

Lucifron wrote:

> Wes G. wrote:
> 
> > I think that’s how it works now, actually.
> > 
> > I scaffolded a new controller and the default layout that was generated  
> > got used until I removed it, and then the global one got used.
> > 
> > Wes  
> > Layouts work this way, yes, but not partials.
> 
> –  
> View this message in context:  
> [http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727](http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727)  
> Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
