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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -