Using different layouts for the entire controller

I have problems with something that should be simple.

I have two use cases ...

  • User is a site directly
  • User is using iframe from another site

I want to do the same in any case, except that I don’t want to use a layout for my site if it is an iframe, so I have a “simple” layout

layout "plain" 

How can I dynamically assign a layout based on the case.

ie params[:iframe] == true , etc.

Nothing of the kind works.

+6
ruby-on-rails layout ruby-on-rails-3 iframe
source share
2 answers

try it

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

How about this

 class FramesController < ApplicationController before_filter :decide_on_layout protected def decide_on_layout layout "plain" if params[:iframe] == "y" end end 
-one
source share

All Articles