Skip to content

Instantly share code, notes, and snippets.

@acook
Last active September 27, 2015 06:17
Show Gist options
  • Save acook/1224384 to your computer and use it in GitHub Desktop.
Save acook/1224384 to your computer and use it in GitHub Desktop.
Set your page title to a sane default.
# This will set your Page Title to a sane default
#
# Usage:
# Put this in your ApplicationHelper.
# Call `title` in your view or layout to display a default title.
# You can set `@title` in your controller action to change the default title.
def title
if @title then
@title
elsif params[:action] == 'index'
params[:controller].titleize
else
"#{params[:action]} #{params[:controller].gsub('devise/', '')}".titleize.singularize
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment