ruby-on-rails - rails : how to add a header to every page

标签 ruby-on-rails header footer code-standards

向 Rails 应用中的每个 View 添加页眉和页脚的标准方法是什么?

最佳答案

如果找到该文件,则会使用该文件。

app/views/layouts/application.html.erb

<!doctype html>
<html>
  <head>
    <!-- stuff -->
  </head>
  <body>
    <!-- this is where content will be rendered -->
    <%= yield %>
  </body>
</html>

否则,您可以调用另一个。

# app/controllers/birds_controller.rb
class BirdsController < ApplicationController

  layout :birds   # looks for app/views/layouts/birds.html.erb

  # ...
end

关于ruby-on-rails - rails : how to add a header to every page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2901436/

相关文章:

ruby-on-rails - Devise Controller 中的 'yield resource' 有什么作用?

CSS 高度问题 - 容器无法拉伸(stretch)(无 float )

mysql - 如果字段长度小于 10 个符号,则 SQL 通过不带 %% 的 like 进行搜索

ruby-on-rails - 嵌套形式的批量赋值

c# - 从 C# 中的原始像素数据创建的位图不会在 IE 中显示

http - 代理应该发送哪些 header ? X-Forwarded-Host 与 X-Host

无法访问单独文件夹中的头文件

java - 使用itext在pdf页脚中创建包含2行的表格

css - 页脚不 float 在底部

mysql - 使用 parent_id 求和并分组