2

I have a Rails 3.2.6 based application using web-app-theme gem. After deploying in production I seeing following errors in /var/log/apache2/error.log.

[Wed Jul 18 23:00:14 2012] [error] [client 50.53.58.188] Premature end of script headers: fonts, referer: https://xxx.xxx.xx.xxx
[ pid=8920 thr=139857209571072 file=ext/apache2/Hooks.cpp:819 time=2012-07-18 23:00:14.743 ]: The backend application (process 9474) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.
[ pid=9474 thr=9488700 file=utils.rb:176 time=2012-07-18 23:00:14.744 ]: *** Exception ActionController::RoutingError in application (No route matches [GET] "/assets/fonts/museosans_500-webfont.svg") (process 9474, thread #<Thread:0x00000001219278>):
    from /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/show_exceptions.rb:53:in `call'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/rack/logger.rb:13:in `call'
    from /usr/lib/ruby/gems/1.9.1/gems/rack-1.3.6/lib/rack/methodoverride.rb:24:in `call'
    from /usr/lib/ruby/gems/1.9.1/gems/rack-1.3.6/lib/rack/runtime.rb:17:in `call'
    from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
.....

I have placed the mentioned file museosans_500-webfont.svg in app/assets/fonts/ directory. But why I am still this error. I also see similar error for other assets like /assets/fonts/museosans_500-webfont.ttf, etc.

Any feedback is much appreciated. Thanks.
-- Atarangp

Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245
Atarang
  • 422
  • 1
  • 6
  • 22

3 Answers3

0

Try add fonts dir to assets path in environment.rb:

config.assets.enabled = true
config.assets.paths << "#{Rails.root}/app/assets/fonts"
Meduza
  • 442
  • 2
  • 7
  • Meduza Thanks, but after adding these entries to the environment.rb I got phusion exceptions for line containing "config". My application.rb file already has "config.assets.enabled = true" entry. So I added your second entry to the application.rb but got the same (orginal) error. Should I add these entries to the production.rb or test.rb file? – Atarang Jul 19 '12 at 09:11
  • Sorry, I have this line in application.rb! – Meduza Jul 19 '12 at 13:13
  • Look at this, maybe it help http://stackoverflow.com/questions/7673988/rails-bundler-precompile-vs-lazy-compile – Meduza Jul 19 '12 at 13:19
  • Meduza, thanks again but it didn't fix the issue. I'm still getting the same errors. – Atarang Jul 20 '12 at 04:16
0

The url in your CSS / HTML seems to be wrong:

/assets/fonts/museosans_500-webfont.svg

You should change that to:

/assets/museosans_500-webfont.svg

But keep the file on the app/assets/fonts directory.

Rudy Matela
  • 6,310
  • 2
  • 32
  • 37
  • You might want to also check [this](http://stackoverflow.com/questions/12329137/how-to-add-a-custom-font-to-rails-app) related answer. – Rudy Matela Jul 26 '13 at 14:15
0

I ran into the same problem when integrating the Katex library.

The issue is that Rails' Asset Pipeline compiles the assets into the public/assets directory without keeping the fonts or images or javascript directories.

So when you're looking for /assets/fonts/museosans_500-webfont.svg, it doesn't exist, that font has been compiled to /assets/museosans_500-webfont.svg.

To solve this you have two options:

  1. Update the path in the CSS or JS:

    /assets/fonts/museosans_500-webfont.svg

    becomes

    /assets/museosans_500-webfont.svg

  2. Put the fonts in a fonts subdirectory:

    If you don't want to (or can't) update the CSS or JS (e.g. it's a minified third party library), then you can use the following method to ensure that there is a public/assets/fonts directory that contains all your fonts.

    Simply put your font(s) in the following path:

    /assets/fonts/fonts/museosans_500-webfont.svg

    Now your public/assets directory will contain a fonts directory and your GET request will be happy.

For more details see this answer.

Community
  • 1
  • 1
Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245