Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to render partial on everything except a certain action

I have a _header.html.erb partial which is where I put my navbar

on my launch page I don't want to display the navbar.

this is the body of application.html.erb

<body> <%= render 'layouts/header' %> <div id="container">     <%= yield %> </div>  </body> 

How do I render it on every action except specific actions on specific controllers?

like image 981
Nick Ginanto Avatar asked Nov 15 '12 10:11

Nick Ginanto


1 Answers

Replace your render with this:

<%= render 'layouts/header' unless @disable_nav %> 

Then you can simply set disable_nav to true in any controller action you like:

def landing_page   @disable_nav = true end 

As a before_filter, which I'd encourage over the above:

application_controller.rb

def disable_nav   @disable_nav = true end 

my_controller

before_filter :disable_nav, only: [:landing_page] 
like image 60
Damien Roche Avatar answered Sep 20 '22 16:09

Damien Roche