Skip to content

Instantly share code, notes, and snippets.

@jordanbyron
Last active December 29, 2015 09:39
Show Gist options
  • Save jordanbyron/7651362 to your computer and use it in GitHub Desktop.
Save jordanbyron/7651362 to your computer and use it in GitHub Desktop.
Targeting specific controllers and actions in your assets while still leveraging the full benefits of the asset pipeline
!!! 5
%html{:lang => 'en'}
%head
%title My Awesome Rails App
= stylesheet_link_tag 'application'
= javascript_include_tag 'application'
= csrf_meta_tag
%body{class: "#{controller.controller_name}-#{controller.action_name}"}
= yield
body.posts-index
color: red
body.posts-new
color: green
if $('body').hasClass 'posts-index'
alert 'Oh hai posts index!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment