ruby - Rails: How to change the title of a page? -


what best way create custom title pages in rails app without using plug-in?

in views this:

<% content_for :title, "title specific page" %> <!-- or --> <h1><%= content_for(:title, "title specific page") %></h1> 

the following goes in layout file:

<head>   <title><%= yield(:title) %></title>   <!-- additional header tags here --> </head> <body>   <!-- if pages contain headline tag, it's preferable put in layout file -->   <h1><%= yield(:title) %></h1> </body> 

it's possible encapsulate content_for , yield(:title) statements in helper methods (as others have suggested). however, in simple cases such 1 put necessary code directly specific views without custom helpers.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -