Rails 4 images of provider objects that Heroku and S3 css files do not reference

I have many vendor images in the Vendor folder referenced by the vendor's css files.

I use Heroku and S3 for production, and a thing like background-image: url("../images/sprite.png"); works in development, but not in production, as the image url points to the S3 url.

It is not precompiled, so I’m not sure whether I should include this as part of the precompilation of assets, but I would like to avoid this, because I need to manually copy all the image files to the assets/images folder, and also change the link in the css files by changing it on scss as well as asset_url (which seems to work fine)

Is there any way not to link to S3-url only from css files of the provider

I also use asset_sync gem to upload to S3

+6
source share
1 answer

Precompile Assets

It seems that you have a problem with the asset fingerprint , and this is a problem that can be solved by precompiling your assets:

Heroku Tutorial :

 #config/environments/production.rb config.assets.compile = true config.assets.digest = true #cmd rake assets:precompile RAILS_ENV=production git add. git commit -a -m "Your Commit" git push heroku master heroku run rake assets:precompile --app your_heroku_app 

This will allow you to precompile all your assets (and synchronize them properly)


Resource Sync

Using the asset_sync with Rails and Heroku, we found that you need to run the precompile command on Heroku itself (the last step in my previous paragraphs)

The only way to check is to look in your Amazon bucket - if it is configured correctly, it must fill in the assets if you precompile on Heroku

+8
source

All Articles