Forum: Ruby on Rails render :partial in /app/views/layouts

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Trevor Menagh (Guest)
on 2009-04-21 23:19
(Received via mailing list)
Hi all,

I have many layouts that apply to parts of my Rails site. Some of the
elements of each of the layouts are the same. I would like to create
something like a partial to use within layouts.

For example, I might have two layouts that have identical <head>
information, but different <body> formatting.

Is there a way to separate out the identical information so I can DRY
up my layout code? I didn't have much luck creating partials in the
layout directory.

Trevor Menagh (Guest)
on 2009-04-22 00:09
(Received via mailing list)
After doing some searching I found nested-layouts (
radar/nested-layouts/tree/master). It seems to do the trick, although
to get it to work with my Rails 2.3.2 app, I had to change part of
line 13 of lib/nested_layouts.rb from 'app/views/layouts' to "#

If anyone has some better/alternative solutions, I am all ears.

Dmitry S. (Guest)
on 2009-04-22 00:13
(Received via mailing list)
Actually partials in the layout directory work fine (like in any other
dir), but you need to specify the directory explicitly:


In application.html.erb
  <%= render :partial => 'layouts/head' %>

This topic is locked and can not be replied to.