I used the same error when using asset_data_uri in my view ( asset_path worked) and could not understand why. This is not exactly your problem, but I was able to fix mine by adding it to my application_helper.rb :
# Copied from Sprockets::Context.asset_data_uri, and slightly modified. def asset_data_uri path asset = Rails.application.assets.find_asset path throw "Could not find asset '#{path}'" if asset.nil? base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "") "data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}" end
source share