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