Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created September 20, 2011 21:42
Show Gist options
  • Save patmaddox/1230489 to your computer and use it in GitHub Desktop.
Save patmaddox/1230489 to your computer and use it in GitHub Desktop.
conditionally link to precompiled assets in rails 3 asset pipeline
module ApplicationHelper
def controller_asset_javascript
javascript_include_tag(controller_name) if Rails.configuration.assets.precompile.include?("#{controller_name}.js") || !Rails.env.production?
end
def controller_asset_stylesheet
stylesheet_link_tag(controller_name) if Rails.configuration.assets.precompile.include?("#{controller_name}.css") || !Rails.env.production?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment