← Back to Upcase

URL Helpers Point to the Correct FIles, But Doesn't Point to the Finger Printed Version Ones in Stylesheets


(Kevin Lozandier) #1

The Problem

It seems that the asset, image helpers in my stylesheets aren’t generated the precompiled equivalents after running ``assets:precompile` (as well as making sure to clear my cache for good measure):

I have my .sass and scss in this matter (with image-url used as well with no luck):

@each $background_set in $background_banners
    
    &.#{nth($background_set, 1) }
      background-image: asset-url("background_banners/#{nth($background_set, 2)}.jpg") 
      background-size: cover  
      min-height: 318px
      
      +breakpoint($hidpi)
        background-image: asset-url("background_banners/#{nth($background_set, 2)}@2x.jpg")
  

It correctly points to the correct assets/ variants, but without the fingerprints generated by assets:precompile.

I’ve also made simple extensions to my config to make sure it’s not the problem

config.assets.paths << "#{Rails.root}/app/assets/fonts"
config.assets.paths << "#{Rails.root}/app/assets/stylesheets/fonts"
config.assets.precompile += %w( personal.css   )
#personal.css is the main stylesheet I use before importing it to the application.scss manifest file. 

After doing things I have had no luck outside of perhaps extending .erb to see if it’ll love having the asset_path duties dedicated it like the guides does with .css files.

But it seems there’s a gotcha issue here to not have to go that route considering the fact the correct path is being generated.

What I’ve done

Including investing what my url helpers are returning in the console using the app and h console variables, I’ve been temporarily able to fix the problem by forcing things to compile on each request on Heroku by using:

  config.assets.compile = true # I thought this was bad practice because it's notoriously slow? 


(Chad Pytel) #2

Can you paste/check all of the config.assets lines you have in config/environments/production.rb?

Here is what I have:

  config.assets.compile = false
  config.assets.digest = true
  config.assets.js_compressor = :uglifier
  config.assets.precompile += %w( print.css prefilled_input.js )

Do you have have config.assets.digest = true?
Can you ensure that you are running in production mode?