Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove header and footer from some of the pages in ruby on rails

I am working in rails project. I created a header and footer and added to all pages in layouts/application.html.erb file. Now I want to remove it from some pages. how can I do that?

like image 772
Om3ga Avatar asked Dec 12 '22 00:12

Om3ga


2 Answers

Controllers support :only and :except options for layouts, see the Conditional layouts section in this guide.

So you can do the following in your controller:

class SomeController < ApplicationController
  layout 'application', :except => [:some_action, :some_other_action]
  ...
like image 168
HargrimmTheBleak Avatar answered May 06 '23 14:05

HargrimmTheBleak


Create a different layout, and apply that in the pages where you don't want to render the header and the footer.

like image 32
Matzi Avatar answered May 06 '23 15:05

Matzi