How to hide the footer layout on a specific page?

On my browse page, I want to hide the partial footer defined in my application.html.erb application, how can I do this?

What parameters do I need to do?

+6
ruby-on-rails
source share
2 answers

The easiest / fastest way is to define a conditional:

<%= render "layouts/footer" unless @skip_footer %> 

and then set the necessary parameters in your actions:

 def non_footer_action do_stuff @skip_footer = true end 
+18
source share

For me, the CSS solution is the closest to the usual one:

app/controllers/resources_controller.rb

 class ResourcesController < ApplicationController def action # ... end end 

app/views/layouts/application.html.erb

 <body class="<%= "#{controller_path} #{action_name}" %>"> <!-- ... --> <footer></footer> </body> 

app/assets/stylesheets/resources.css.scss

 body.resources { // Hide footer for certain views &.action footer { display: none; } } 

You can also use a separate layout for footerless actions, although one element is not a sufficient reason for another layout.

+1
source share

All Articles