Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Automatic Body ID in Rails
###############################################
# 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">
http://www.fivesevensix.com/posts/2005/04/15/automatic-body-tag-id-with-rails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment