Skip to content

Instantly share code, notes, and snippets.

@HatemMahmoud
Created March 22, 2010 17:05
Show Gist options
  • Save HatemMahmoud/340273 to your computer and use it in GitHub Desktop.
Save HatemMahmoud/340273 to your computer and use it in GitHub Desktop.
A simple way to customize page title in Rails controllers
#in products_controller.rb
before_filter :set_title
def set_title
# default title for this controller
@title = 'Products'
end
def index
# different title for this action
@title = 'Catalog'
end
#in application.rhtml.erb
<title><%= @title.titleize + ' - My Great Store' %></title>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment