Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guilleiguaran/9211738 to your computer and use it in GitHub Desktop.
Save guilleiguaran/9211738 to your computer and use it in GitHub Desktop.
Sprockets Processor for paths fixing
body{background-image:url("/assets/bg-ef8538157f3dc9558b9443c31ccd896c.jpg")}
body
{
background-image: url('/assets/bg.png');
}
class AssetPathProcessor < Sprockets::Processor
def evaluate(context, locals)
data.gsub(%r{["|']/assets/(.+)["|']}) do
'"' + context.asset_path($1) + '"'
end
end
end
require 'asset_path_processor'
Rails.application.assets.register_preprocessor('text/css', AssetPathProcessor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment