Module: AbstractController::Layouts::ClassMethods::LayoutConditions

Defined in:
actionpack/lib/abstract_controller/layouts.rb

Overview

This module is mixed in if layout conditions are provided. This means that if no layout conditions are used, this method is not used

Instance Method Summary collapse

Instance Method Details

#conditional_layout?Boolean

Determines whether the current action has a layout by checking the action name against the :only and :except conditions set on the layout.

Returns

  • Boolean - True if the action has a layout, false otherwise.

Returns:

  • (Boolean)


221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'actionpack/lib/abstract_controller/layouts.rb', line 221

def conditional_layout?
  return unless super

  conditions = _layout_conditions

  if only = conditions[:only]
    only.include?(action_name)
  elsif except = conditions[:except]
    !except.include?(action_name)
  else
    true
  end
end