Adding '*.png'
to config.assets.precompile
precompiled all the images and seems to have fixed the issue.
Bootstrap 2 Glyphicons not working with Rails 4
-
09-07-2023 - |
Frage
I have bootstrap-sass 2.0 installed, and recently updated from Rails 3.2 to Rails 4.1. Now the glyphicons don't work in production.
For example, no icon shows up for this:
<i class="icon-zoom-in"></i>
I tried installing the 'non-stupid-digest-assets' gem and also added the following line to production.rb:
config.assets.precompile += %w( '.woff', '.eot', '.svg', '.ttf' )
but they still don't work. How do I fix it? The bootstrap.css file is created from the gem, so I don't want to edit it directly.
Update
The issue is that the icons get CSS for an image that does not exist, such as:
background-image: url(/assets/glyphicons-halflings-d8bbe73c5fea83aefd24440ba9988084.png)
Below is part of my gemfile:
source 'https://rubygems.org'
ruby '2.1.1'
gem 'rails', '4.1'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.0.1'
gem 'bootstrap-sass', '2.0.0'
gem 'will_paginate', '3.0.5'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'font-awesome-sass', '~> 4.0.3'
group :assets do
gem 'sass-rails', '~> 4.0.3'
gem 'coffee-rails'
gem 'uglifier', '1.2.3'
gem "non-stupid-digest-assets"
end
gem 'jquery-rails'
Lösung 2
Andere Tipps
Manually place your icons within /vendor/assets/fonts for a quick fix.
The following is from the Rails upgrade guide found at: http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html
In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. Rails application and engine developers should put these assets in app/assets or configure config.assets.precompile.
So make sure your 'bootstrap-sass' (version 2.0.0) gem has placed the assets in the app/assets directory.