I'm doing the following in my application template:
<%= yield(:content) or yield %>
I have a questions template that is nested within the application template. However, for my questions index, I want just want to display the application template, not the questions template.
As such, I override it like this:
format.html { render :layout => "application"}
This overrides the template fine such that the application template is rendered, not the question template. However, it doesn't seem like the "or yield" statement is working; my content is blank. It works fine when I change the application template to this:
<%= yield %>
I need the original statement though so I can have the nested template. I'd prefer not to have to write content_for's across the entire site in order to have a nested template.
Any thoughts?
Something like this should do the trick:
In place of
<%= yield(:content) or yield %>
use:
<%= content_for?(:content) ? yield(:content) : yield %>
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With