Following this tutorial (https://www.railstutorial.org/book/rails_flavored_ruby), I wish to vary the title of a layout based on the controller.
I have my page in four sections which I can change at will. It is working well excpet I am having a hard time changing the title.
Here is my layout:
<html>
<head>
<%= stylesheet_link_tag "ERP" %>
<title><%= yield(:title) %></title>
</head>
<body>
<%= render 'header' %>
<%= render "sidebar" %>
<%= render "content" %>
<%= render "footer" %>
</body>
</html>
I tried to add the title in the controller but it did not work:
class ViewerController < ApplicationController
def index
provide(:title, "Viewer")
end
def update
end
end
I get the error "undefined method `provide' for #". We will have more apps that use the same layout, changing what sections they need to. I would like to change the title based on the app.
Anyone know how I can use the provide function in a controller?