sulleh
sulleh

Reputation: 331

Heroku can't find some of my rails assets

I'm new to web development, and I've been working on a simple app for learning purposes. I've been able to deploy to Heroku from my local machine, but for some reason, the custom classes that I use for some vector images aren't rendering on Heroku.

This is my page, and as you can see, there are just squares where there should be different images. Looking in the inspector, you see the following errors:

Failed to load resource: the server responded with a status of 404 (Not Found) - https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.woff

Failed to load resource: the server responded with a status of 404 (Not Found) https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.ttf 

I have tried recompiling assets, recommitting, and pushing to Heroku, but this error persists. What's weird is that if I use Heroku Bash and view the Heroku file directory, it looks like the files are there:

directory of Heroku files

But they are still throwing up that error in the inspector. I've also got the following set in my production.rb file:

config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.compile = true
config.assets.js_compressor = :uglifier

Any idea what could be causing this asset issue? I'm using Rails 4.2.0.

Upvotes: 1

Views: 599

Answers (1)

sulleh
sulleh

Reputation: 331

I was able to answer my own question after reading through this link. Essentially, I moved the font files out of my CSS directory and into their own fonts directory under the app/assets directory, and then in production.rb added the following line to the Application class:

config.assets.paths << Rails.root.join("app", "assets", "fonts")

and presto! It worked. I didn't mess around with @font-face in CSS, since the assets I'm using from flat-icons are built through custom classes used in span or div blocks.

Upvotes: 1

Related Questions