Module: LayoutOptions::ClassMethods

Defined in:
lib/layout_options/layout_options.rb

Instance Method Summary collapse

Instance Method Details

#layout_options(args = {}) ⇒ Object

layout_options - This method is available at the class level of your ApplicationController and any controller that inherits from it.

layout_options accepts a single hash where the index is the layout name and the is the controller method(s) that will be using that layout. If you set the index to :none no layout will be used. If no layout is specified it will default to using the ‘application’ layout.

All of the following examples will work controllers that inherit from InheritedResources::Base.

# setting an overlay layout for a new method
class UsersController < ApplicationController
  layout_options :overlay => :new
end

# setting an overlay layout for multiple methods
class UsersController < ApplicationController
  layout_options :overlay => [:new, :edit]
end

# not using a layout
class UsersController < ApplicationController
  layout_options :none => [:create, :destroy]
end

# using multiple layouts
class UsersController < ApplicationController
  layout_options :overlay => [:new, :edit], :none => [:create, :destroy],
    :foo => :show
end


56
57
58
# File 'lib/layout_options/layout_options.rb', line 56

def layout_options(args={})
  LayoutOptions::Storage[controller_name] = args
end