1

I compiled my assets without errors they work in development environment without problems but they all broke in production. I checked my log file it seems that it's not referencing the correct location. This is one of the errors.

INFO -- : Started GET "/homeFoods/fonts/glyphicons-halflings-regular.woff2" for 132.241.174.123 
at 2016-04-08 22:35:59 +0000 F, [2016-04-08T22:35:59.294695 #26882] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.woff2"):

actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.5) lib/rails/engine.rb:518:in `call'
railties (4.2.5) lib/rails/application.rb:165:in `call'
passenger (5.0.24)   src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
 passenger (5.0.24)   
  src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'     passenger(5.0.24)src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'passenger(5.0.24) src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads' passenger(5.0.24) src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'

Why it's assuming that fonts directory is located under homeFoods not /homeFoods/app/assets/ ?

application.rb

config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.assets.precompile += %w( .svg .eot .woff .ttf )

bootstrap.css

font-face {
 font-family: 'Glyphicons Halflings';
 src: url('/assets/glyphicons-halflings-regular.eot');
  src: url('/assets/glyphicons-halflings-regular.eot?#iefix') 
format('embedded-opentype'), url('/assets/glyphicons-halflings-regular.woff') format('woff'), url('/assets/glyphicons-halflings-regular.ttf') format('truetype'), url('/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');}

I did try this approach Bootstrap 3+Rails 4 - Certain Glyphicons not working which used to work but not anymore.I do not know why it was working because the path he's specifying is not correct, vendor does not contain fonts folder.

   config.assets.paths << "#{Rails}/vendor/assets/fonts"
Community
  • 1
  • 1
A1X
  • 1,099
  • 3
  • 8
  • 11

1 Answers1

0

In cases like this I just create a new file icons.css.scss and use asset-url helper inside. For example:

@font-face { font-family: 'EntypoRegular'; src: asset-url('fontello.eot'); src: asset-url('fontello.eot?#iefix') format('embedded-opentype'), asset-url('fontello.ttf') format('truetype'), asset-url('fontello.woff') format('woff'), asset-url('fontello.svg#EntypoRegular') format('svg'); }

Next I include this file in my application.css.scss by adding //= require icons. Hope this help.

Radek
  • 202
  • 2
  • 6