Rails 3 - Ideal way to set title of pages

后端 未结 13 1235
失恋的感觉
失恋的感觉 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 07:12

    you could a simple helper:

    def title(page_title)
      content_for :title, page_title.to_s
    end
    

    use it in your layout:

    <title><%= yield(:title) %></title>
    

    then call it from your templates:

    <% title "Your custom title" %>
    

    hope this helps ;)

    0 讨论(0)
提交回复
热议问题