开发者

Rails get title

开发者 https://www.devze.com 2023-04-08 17:36 出处:网络
How can I get the title of my page using Rails? conte开发者_C百科nt_for will set it, so is there a better way than to assign it to an instance variable?If your\'e using content_for to set it, you can

How can I get the title of my page using Rails? conte开发者_C百科nt_for will set it, so is there a better way than to assign it to an instance variable?


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消