In one of my controllers I want to change the layout given some condition, and otherwise keep the default layout used by the parent ApplicationController (was "application" initially, but I'm trying some others now). Tried accessing the "layout" using alias_method but it doesn't seem to work. My code:
class SomeController < ApplicationController
alias_method :parent_layout, :layout
layout :some_layout
def some_layout
if some_condition
"new_layout"
else
:parent_layout
end
end
end
This gives an error:
ActionController::RoutingError (undefined method `layout' for class `SomeController'):
app/controllers/some_controller.rb:6:in `alias_method'
app/controllers/some_controller.rb:6:in `<class:SomeController>'
app/controllers/some_controller.rb:3:in `<top (required)>'