Rails assets is having issues with my fonts -
both locally , in heroku having issues fonts.
rails 4.2.5.1
my fonts in app/fonts folder:
/app/assets/fonts/fontawesome-webfont.eot /app/assets/fonts/fontawesome-webfont.svg /app/assets/fonts/fontawesome-webfont.ttf /app/assets/fonts/fontawesome-webfont.woff /app/assets/fonts/fontawesome-webfont.otf
the error message:
started "/assets/fonts/fontawesome-webfont.ttf?v=4.2.0" ::1 @ 2016-06-01 22:12:24 -0400 actioncontroller::routingerror (no route matches [get] "/assets/fonts/fontawesome-webfont.ttf"): actionpack (4.2.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call' web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch' web-console (2.3.0) lib/web_console/middleware.rb:18:in `call' actionpack (4.2.5.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.2.5.1) lib/rails/rack/logger.rb:38:in `call_app' railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
config/initializers/assets.rb has:
rails.application.config.assets.version = '2.0'
what issue here, confused?
although rails has store assets in assets/javascripts
, assets/stylesheets
, assets/fonts
, or whatever, directories not map directly urls. instead served /assets
. in browser's location bar type http://localhost:3000/assets/fontawesome-webfont.ttf , bet you'll font.
so should find whatever referencing font, , fix url there (probably in css file). but note in production rails mangles names of these assets make them more cachable, correct url in production http://example.com/assets/fontawesome-webfont-asdfasasdfadsfadfsasf23kjksdjkasdfadsf.ttf. can make sure right url using asset_path helper. there asset_url
, image_path
, etc. there font_path
!