In one of our app, the content_for is used to set the page title from a helper method. It looks something like this:
which when used in a view template like so:
will return the title
We use monologue for our blog engine. Monologue is for a fact also setting the content for
:title which resulted in a real mess!
Why that? The reason is pretty simple: When calling multiple time the content_for method for a given key, Rails will append their body together. What seems to be a sensible default implementation did not fit our title requirements.
It is possible to delete the content defined for a given key like so:
Which I simply added in our title method above:
And that’s it… our titles are shining again!