What is the standard way to add a header and footer to every view in a Rails app?
If this file is found, it will be used.
<!doctype html>
<html>
<head>
<!-- stuff -->
</head>
<body>
<!-- this is where content will be rendered -->
<%= yield %>
</body>
</html>
Otherwise, you can call in a different one.
# app/controllers/birds_controller.rb
class BirdsController < ApplicationController
layout :birds # looks for app/views/layouts/birds.html.erb
# ...
end
put the header and footer into the application layout which can be found at app/views/layouts/application.html.erb.You may have to create this file first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With