following tutorial (https://www.railstutorial.org/book/rails_flavored_ruby), wish vary title of layout based on controller.
i have page in 4 sections can change @ will. working excpet having hard time changing title.
here 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 add title in controller did not work:
class viewercontroller < applicationcontroller def index provide(:title, "viewer") end def update end end i error "undefined method `provide' #". have more apps use same layout, changing sections need to. change title based on app.
anyone know how can use provide function in controller?
i believe you're looking in controller not provide but:
content_for :title, 'viewer'
Comments
Post a Comment