I tried to create a helper module to be able to set the title of a page. Of course it's not working (reference) Is there something I must define in a controller for my helpers methods to be seen by my controllers??
Gitlink: works_controller.rb
def index
set_title("Morning Harwood")
@works = Work.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @works}
end
end
module ApplicationHelper
def set_title(title = "Default title")
content_for :title, title
end
end
In the layout work.html.erb:
<%= content_for?(:title) ? content_for(:title) : 'This is a default title' %>