What is the best way to create a custom title for pages in a Rails app without using a plug-in?
You can also set it in a before_filter in your controller.
# foo_controller.rb
class FooController < ApplicationController
before_filter :set_title
private
def set_title
@page_title = "Foo Page"
end
end
# application.html.erb
<%= page_title %>
You can then set conditions in the set_title method to set a different titles for different actions in the controller. It's nice to be able to see all the relevant page titles within your controller.