instance method layout

Ruby on Rails 4.1.16

Since v4.1.16

Available in: v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

layout(layout, conditions = {})

Specify the layout to use for this class.

If the specified layout is a:

String

the String is the template name

Symbol

call the method specified by the symbol, which will return the template name

false

There is no layout

true

raise an ArgumentError

nil

Force default layout behavior with inheritance

Parameters

  • layout - The layout to use.

Options (conditions)

  • :only - A list of actions to apply this layout to.

  • :except - Apply this layout to all actions but this one.

Parameters

layout req
conditions opt = {}
Source
# File actionview/lib/action_view/layouts.rb, line 262
      def layout(layout, conditions = {})
        include LayoutConditions unless conditions.empty?

        conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
        self._layout_conditions = conditions

        self._layout = layout
        _write_layout_method
      end

Defined in actionview/lib/action_view/layouts.rb line 262 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Layouts::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close