Created
July 5, 2011 21:14
-
-
Save Lytol/1065962 to your computer and use it in GitHub Desktop.
Body tag helper that sets class and id based on controller/action
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
def body_tag(&blk) | |
controller_name = controller.class.to_s.underscore.gsub(/_controller$/, '').gsub(/\//,'_') | |
action_name = controller.action_name.underscore.gsub(/_/,'-') | |
content_tag(:body, :id => "#{controller_name}-#{action_name}", :class => controller_name, &blk) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment