# Using layout of different controller

**URL:** <https://www.ruby-forum.com/t/using-layout-of-different-controller/145064>\
**Category:** Rails\
**Created:** [August 5, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/using-layout-of-different-controller/145064 "2008-08-05T18:19:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 5, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/using-layout-of-different-controller/145064/1 "2008-08-05T18:19:54Z")

</div>

How could I use the layout of a different controller?

Thanks

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 5, 2008, 6:50pm UTC](https://www.ruby-forum.com/t/using-layout-of-different-controller/145064/2 "2008-08-05T18:50:23Z")

</div>

Hubert ÅÄ™picki wrote:

> class MyController \< ActionController::Base  
> layout “myotherlayout”  
> …  
> end
> 
> will use app/view/layouts/myotherlayout.html.erb file

Sweet, seems like that works, but in my layout I’m rendering partials  
that are in a different controller as well, how do I go about that?

Thanks

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 5, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/using-layout-of-different-controller/145064/3 "2008-08-05T18:42:40Z")

</div>

class MyController \< ActionController::Base  
layout “myotherlayout”  
…  
end

will use app/view/layouts/myotherlayout.html.erb file

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 5, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/using-layout-of-different-controller/145064/4 "2008-08-05T19:19:00Z")

</div>

Justin To wrote:

> Hubert ÅÄ™picki wrote:
> 
> > class MyController \< ActionController::Base  
> > layout “myotherlayout”  
> > …  
> > end
> > 
> > will use app/view/layouts/myotherlayout.html.erb file
> 
> Sweet, seems like that works, but in my layout I’m rendering partials  
> that are in a different controller as well, how do I go about that?
> 
> Thanks

In the layout, instead of saying  
\<%= render :partial =\> ‘apple\_partial’ %\>

use this instead:  
\<%= render :partial =\> ‘apples/apple\_partial’ %\>

where “apples” is the name of the view folder that the partial is in.

HTH,  
Joe
