Created
March 6, 2012 21:22
-
-
Save bigjason/1989047 to your computer and use it in GitHub Desktop.
Rails Javascript/CSS Path outside of a controller
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
# 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