layout(template_name, conditions = {}, auto = false) public

If a layout is specified, all rendered actions will have their result rendered when the layout yields. This layout can itself depend on instance variables assigned during action performance and have access to them as any normal template would.

Show source
Register or log in to add new notes.
August 7, 2008
9 thanks

Function to Determine Layout

Sometimes its nice to have different layouts choosen automagicly:

 class ApplicationController < ActionController::Base
  layout :determine_layout
  def determine_layout
    if is_admin?
      "admin"
    else
      "application"
    end
 ...
 end
June 30, 2008
8 thanks

Turn layout off

If you don’t want a layout rendered, just put:

   layout nil

in your controller.

July 15, 2008
7 thanks

Required Reading

The details for using layout (such as possible values for the conditions hash) can be found in ActionController::Layout::ClassMethods.

September 17, 2008
2 thanks

Turn layout off with render

Thats awkward, but the code below does not turn layout off:

  render :action => "short_goal", :layout => nil

you must use false

  render :action => "short_goal", :layout => false
July 4, 2008
2 thanks

Using a specific layout

To choose the layout (or no layout) for a method call the render method with a :layout option.