Ruby on Rails - How do I render an action without the application layout?

前端 未结 2 1286
借酒劲吻你
借酒劲吻你 2021-02-02 05:14

I have a rails app and I want to render an action without using my application layout (which has page header / footer stuff in it).

How could I go about doing this?

相关标签:
2条回答
  • 2021-02-02 05:20

    For Rails 5, in the controller, for the specific action:

    def action
      render layout: false
    end
    
    0 讨论(0)
  • 2021-02-02 05:25

    Here's some documentation about it: http://guides.rubyonrails.org/layouts_and_rendering.html

    For your question:

    render :layout => false
    

    or

    layout false
    
    0 讨论(0)
提交回复
热议问题