Rails 3 - Ideal way to set title of pages

后端 未结 13 1236
失恋的感觉
失恋的感觉 2020-12-04 06:33

Whats the proper way to set the page title in rails 3. Currently I\'m doing the following:

app/views/layouts/application.html:


  

        
13条回答
  •  离开以前
    2020-12-04 06:45

    There's no need to create any extra function/helper. You should have a look to the documentation.

    In the application layout

    <% if content_for?(:title) %>
      <%= content_for(:title) %>
    <% else %>
      Default title
    <% end %>
    

    In the specific layout

    <% content_for :title do %>
      Custom title
    <% end %>
    

提交回复
热议问题