Rails 3: How to properly fetch layout name?

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” :slight_smile: So, is the deprecation
message mentioned above already deprecated? :slight_smile:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs