holden
holden

Reputation: 13581

using different layouts for an entire controller

I'm having problems with something that should be simple.

I have two use cases...

I want to do the same thing in either case except I don't want to use the layout for my website in the case it's the iframe so I have a "plain" layout

layout "plain"

How can I dynamically assign the layout depending on the case..

ie params[:iframe] == true etc.

Nothing I do seems to work.

Upvotes: 6

Views: 3479

Answers (2)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

How about this

class FramesController < ApplicationController
  before_filter :decide_on_layout


  protected
  def decide_on_layout
    layout "plain" if params[:iframe] == "y"
  end

end

Upvotes: -1

Jonathan
Jonathan

Reputation: 16349

try this

layout :layout_by_resource

def layout_by_resource
  if params[:iframe] == true
    'plain'
   else
    "your-main-layout"
  end
end

Upvotes: 8

Related Questions