0

Please excuse my noobness, I'm new to much of RoR.

I am having trouble getting my images to load when I deploy them to Heroku.

I have two images that load from a css file, which I moved to scss.

Initially I had

background: url(../images/k-opacity-70.png);

background: #111 url(../images/intro-bg.jpg) no-repeat center;

in a layout.css file

Then I noticed everything worked fine locally, but the images don't load when I deploy them to Heroku.

After some research and a multitude of different attempts, I now have

background: image-url('k-opacity-70.png');
background: #111  image-url('intro-bg.jpg')  no-repeat center;

in a file called layout.css.scss

Once again, the images work properly locally, but not when I deploy my app to Heroku.

Can anyone tell me what I am doing wrong?

My app is at blooming-coast-2140.herokuapp.com

----Update--- I've tried done the things seen in similar posts here and other websites with no luck...

gem ‘rails_12factor’, group: :production  

config.serve_static_assets = true
config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’
config.assets.compile = true

heroku run rake assets:precompile

rake assets:precompile RAILS_ENV=production

1 Answers1

0

In your site CSS everything looks fine. Image is loaded properly. You are using file

http://blooming-coast-2140.herokuapp.com/assets/k-opacity-70-26821b89b8efd61bf304cc109d3af47e.png and this file exists

To make it work via image-url you should set up properly in your settings:

http_path = "../"
images_dir = "img"
relative_assets = true

Those are from my configuration from Compass. You should change them depending on your folders structure.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291