ruby-on-rails – Rails:如何向每个页面添加标题

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rails:如何向每个页面添加标题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在Rails应用程序的每个视图中添加页眉和页脚的标准方法是什么?

解决方法

如果找到该文件,它将被使用.

应用程序/视图/布局/ application.html.erb

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <!-- stuff -->
  5. </head>
  6. <body>
  7. <!-- this is where content will be rendered -->
  8. <%= yield %>
  9. </body>
  10. </html>

否则,您可以拨打其他电话.

  1. # app/controllers/birds_controller.rb
  2. class BirdsController < ApplicationController
  3.  
  4. layout :birds # looks for app/views/layouts/birds.html.erb
  5.  
  6. # ...
  7. end

猜你在找的Ruby相关文章