ruby-on-railsrubyruby-on-rails-3viewcontent-for

How to skip the content_for tag content for some pages in rails?


I have a layout in which i'm using the content_for tag to render some partials(for sidebar). But on several pages I don't need this sidebar. So the question is: How can I tell rails not to render anything for some pages?

I've tried to do it the following way without any result:

<% content_for :sidebar do %>
  <%= render nothing: true %>
<% end %>

Just got an error

You invoked render but did not give any of :partial, :template, :inline, :file or :text option.

Solution

  • don't specify content_for in views you don't want to see the contents