Skip to content

Instantly share code, notes, and snippets.

@tjh
Forked from timnovinger/bodyid.rb
Created October 14, 2009 13:40
Show Gist options
  • Save tjh/210083 to your computer and use it in GitHub Desktop.
Save tjh/210083 to your computer and use it in GitHub Desktop.
###############################################
# place in /app/helpers/application_helper.rb #
###############################################
def bodytag_id
a = controller.class.to_s.underscore.gsub(/_controller$/, '')
b = controller.action_name.underscore
"#{a}-#{b}".gsub(/_/, '-')
end
#################
# place in html #
#################
<body id="<%= bodytag_id %>" class="standard">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment