# Rails 3: How to properly fetch layout name?

**URL:** <https://www.ruby-forum.com/t/rails-3-how-to-properly-fetch-layout-name/183854>\
**Category:** Rails\
**Created:** [February 21, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/rails-3-how-to-properly-fetch-layout-name/183854 "2010-02-21T21:38:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [February 21, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/rails-3-how-to-properly-fetch-layout-name/183854/1 "2010-02-21T21:38:27Z")

</div>

Hi,

I’m trying to update shoulda gem to be Rails 3 compatible and got a  
problem with fetching layout name. There’s the following code in  
shoulda:

```
@controller.response.layout

```

which in Rails 2 returns i.e. ‘layouts/application’. When this code is  
executed in Rails 3, Rails prints out deprecation warning that  
‘template.layout’ should be used instead. However, the ‘template’  
method is defined in ActionController::Compatibility module and  
returns ‘view\_context’ object. Additionally it has the following  
comment: “TODO: Remove this after we flip” 🙂 So, is the deprecation  
message mentioned above already deprecated? 🙂

What’s the proper way to fetch layout name?  
@controller.template.layout? @controller.view\_context.layout? Besides,  
response.layout returns just a layout name, while template.layout  
returns a full path to a layout file (i.e. “/Users/…/views/layouts/  
application.html.erb”) - is there a way to get response.layout like  
result in Rails 3?

Cheers,  
Szymek
