LanguagesNamedAfterCofee
LanguagesNamedAfterCofee

Reputation: 5952

Rails get title

How can I get the title of my page using Rails? content_for will set it, so is there a better way than to assign it to an instance variable?

Upvotes: 0

Views: 909

Answers (1)

numbers1311407
numbers1311407

Reputation: 34072

If your'e using content_for to set it, you can simply use content_for to get it as well.

<% content_for :title, "My Title" %>

Some time later ... 
<title><%= content_for :title %></title>
...
<h1><%= content_for :title %></h1>

Upvotes: 1

Related Questions