Created
March 22, 2010 17:05
-
-
Save HatemMahmoud/340273 to your computer and use it in GitHub Desktop.
A simple way to customize page title in Rails controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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