Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: How to get the name of the current layout?

In my controller I have:

render :layout => 'mobile'

In my view I want to be able to get the name of the layout, in this case "mobile".

I don't need the controller or action name...just the name of the layout.

I'm using Rails 3.0.6.

like image 855
Shpigford Avatar asked Dec 27 '22 08:12

Shpigford


1 Answers

I was late, but try this:

controller.send(:_layout).virtual_path.name

Tested in Rails 3.2

like image 162
Marco Godínez Avatar answered Jan 07 '23 10:01

Marco Godínez