Reputation: 266970
On my view page, I want to hide the footer partial that is defined in my application.html.erb, how can I do this?
what options do I have to do this?
Upvotes: 6
Views: 4304
Reputation: 557
If the page is 'show.html.erb' you can do the following:
<% unless action_name == "show" %>
<%= render 'shared/footer' %>
<% end %>
Upvotes: 1
Reputation: 8303
For me, CSS
solution is the closest to the conventional 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 may also want to use separate layout for «footerless» actions, albeit one element is not good enough reason for another layout.
Upvotes: 1
Reputation: 159105
The easiest/quickest way would probably be to define a conditional:
<%= render "layouts/footer" unless @skip_footer %>
and then set the variable as necessary in your actions:
def non_footer_action
do_stuff
@skip_footer = true
end
Upvotes: 20