class ApplicationAssets
Wrapper class for our applications’s Sprockets environment.
Constants
- ASSET_ROOT
-
request path prepended to each asset – this is where the Rack app is mounted OR a directory within /public containing compiled assets
Public Class Methods
Source
# File lib/application_assets.rb, line 14 def initialize super(File.join(__dir__, '..')) %w[config images javascripts stylesheets].each do |dir| append_path "assets/#{dir}" end append_path 'node_modules' end
Configure Sprockets’ search paths here
Calls superclass method
Public Instance Methods
Source
# File lib/application_assets.rb, line 27 def asset_path(file, digest: false) method = digest ? :digest_path : :logical_path ASSET_ROOT + find_asset(file).send(method) end
Returns an HTTP path that will resolve to the requested asset. The optional digest: parameter will cause the return result to include the hexidigest of the asset so that it will resolve to a compiled, digested asset in production.