Skip to content

Instantly share code, notes, and snippets.

@bigjason
Created March 6, 2012 21:22
Show Gist options
  • Save bigjason/1989047 to your computer and use it in GitHub Desktop.
Save bigjason/1989047 to your computer and use it in GitHub Desktop.
Rails Javascript/CSS Path outside of a controller
# Small snippet to get the paths of linked files for an asset. For use during development only.
# AssetPaths has built in support to resolve paths
ap = ActionView::Helpers::AssetTagHelper::AssetPaths.new(Rails.configuration.action_controller)
# Find the asset directly on the sprockets environment
a = Rails.application.assets.find_asset("crm")
# Compute the public facing paths
a.to_a.map{|path| ap.compute_public_path(path.logical_path, 'javascripts') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment