Created
October 14, 2009 13:37
-
-
Save timnovinger/210079 to your computer and use it in GitHub Desktop.
Automatic Body ID in Rails
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
############################################### | |
# 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