views:

251

answers:

2

How can I print out the name of current layout in a view?

Example

puts controller.current_layout

Thx

+1  A: 

<%= controller.active_layout %> gets you the layout file name. So layout 'application' would return layouts/application.html.erb

In Rails 2.1.0 and greater.

Tony Fontenot
ow... path to a layout... ok... thx.
xpepermint
The problem when I want to set layout for an action like this "layout 'widget', :only => [:account, :verify]". In this case controller.active_layout always returns "widget". Fix?
xpepermint
+2  A: 

This works for me: response.layout

xpepermint