It depends on what you want to do.
To display the title immediately, do:
= content_for :header do %h1 Title
To save the content and use it later, do:
- content_for :header do %h1 Title
And use it somewhere in your views:
= content_for :header
In Rails <3.2, you needed to use = yield :header . This is still supported in Rails 3.2, but it doesnβt work in auxiliary modules, and content_for does (thanks @drewish).
gylaz
source share