Turn off layout for one of action

后端 未结 4 1754
遇见更好的自我
遇见更好的自我 2020-12-08 01:20

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 vie

相关标签:
4条回答
  • 2020-12-08 02:02

    In the respond block, add layout: false.

    For example:

    respond_to do |format|
      format.html { render :layout => false } # your-action.html.erb
    end
    
    0 讨论(0)
  • 2020-12-08 02:09

    This should do it,

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

    Link to Documentation

    0 讨论(0)
  • 2020-12-08 02:14

    If you want to get a non-standard template, with no layout you can use:

    def non_rest
      render template: 'layouts/something_new', layout: false
    end
    
    0 讨论(0)
  • 2020-12-08 02:26

    Try this:

    ReportsController < ApplicationController
      layout false
      layout 'application', :except => :view
    
    0 讨论(0)
提交回复
热议问题