Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off layout for one of action

My situation: View action of ReportsController should render pure html, but not as a file (to view it in browser and save it after). So for rendering I use view template view.html.erb and i neet to turn off any layouts for this action. But in other actions of this controller layouts should stay untouched. Works only turning off for whole controller like this:

ReportsController < ApplicationController   layout false 

But that doing it wrong :( for all the actions I tried to use something like this in action:

def view         @report = Report.new(params[:report])   unless @report.valid?     render :action => 'new' and return   else     render :layout => false        end    end 

What should I do?

like image 512
Antiarchitect Avatar asked Jan 14 '10 05:01

Antiarchitect


2 Answers

This should do it,

def view     ...     render :layout => false end 

Link to Documentation

like image 176
David Ortiz Avatar answered Oct 03 '22 00:10

David Ortiz


Try this:

ReportsController < ApplicationController   layout false   layout 'application', :except => :view 
like image 34
mckeed Avatar answered Oct 03 '22 00:10

mckeed