on-internet
← Community

Rails - How can I detect if the content_for content was provided?

Stack Overflow ·

I want to detect if content was provided for content_for tag in my template, and if not fall back to default value: <title> <% if content_is_provided -%> <%= yield :title -%> <% else -%> 404 - Page Unknown <% end -%> </title> Any easy way to detect this? I tried <% if :title -%> but that didn't do much. thanks.

Comments

Sign in or sign up to comment and upvote.

No comments yet.