Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glyphicons not properly precompiling in Production Rails

With Rails 4 I have run into an issue where glyphicons from Bootstrap are not being properly precompiled. The below is generated:

started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png" for          127.0.0.1 at 2014-01-13 18:41:25 -0500
Started GET "/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png" for 127.0.0.1 at 2014-01-13 18:41:25 -0500
Processing by ApplicationController#routing_error as PNG
Processing by ApplicationController#routing_error as PNG
  Parameters: {"path"=>"assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3"}
  Parameters: {"path"=>"assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3"}
  Rendered public/404.html (0.3ms)
  Rendered public/404.html (0.3ms)
Completed 404 Not Found in 17ms (Views: 3.4ms | ActiveRecord: 8.0ms)
Completed 404 Not Found in 17ms (Views: 3.4ms | ActiveRecord: 8.0ms)

It works fine in development. And if I set config.assets.compile = true in production.rb it seems to work fine - but I understand that to be very bad based on this SO question: files produced by asset:precompile don't match urls generated by stylesheet_link_tag (missing digest) in minimal rails 4 site

This was not an issue for me in Rails 3.2.

Any help would be greatly appreciated!

like image 325
cman77 Avatar asked Jan 13 '14 23:01

cman77


1 Answers

I had the same problem when upgrading an app from Rails 3.2 to 4.

Production app is hosted on Heroku

Everything worked fine in Rails 3.2

However in Rails 4, the Glyphs showed up fine in Dev but not in Production. A quick check of the browser console showed a 404 as the asset path was wrong.

In my case I needed

config.assets.precompile += [
        'twitter/bootstrap/glyphicons-halflings.png',
        'twitter/bootstrap/glyphicons-halflings-white.png'
      ]
like image 120
Techiedog Avatar answered Sep 20 '22 12:09

Techiedog