gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 17:59:04 25 4
gpt4 key购买 nike

向 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com