How can I set the page title in some views and use a default title if it's not set?
I use HAML. What is right way of doing it?
Now I do like:
- content_for :title, "Title for specific page"
and in layout:
%title= h yield(:title)
But how to set this title, but if it doesn't exist, set some default value?
Use the content_for?
method as described in the Rails API
content_for?(:title) ? yield(:title) : "default title"
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