6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails 4.1 + gem 'bootstrap-sass' で発生するエラー対策

Last updated at Posted at 2014-04-11

Rails 4.1 で gem 'bootstrap-sass' を使おうとしたらこんなエラーが。

Asset depends on 'bootstrap/glyphicons-halflings-regular.eot' to generate properly but has not declared the dependency
Please add: `//= depend_on_asset "bootstrap/glyphicons-halflings-regular.eot"` to

Rails 4.1 から sprockets_better_errors という gem が追加されているのが原因のようです。
sprockets_better_errors は development モードでも assets precompile のエラーが検出できるようにするものらしいのですが、この影響でデフォルトでは bootstrap-sass が動きませんでした。

いろいろ調べた結果、以下の記述でこのエラーを回避することができました。

Gemfile
gem 'bootstrap-sass'
app/assets/stylesheets/application.css.sass
//= depend_on_asset "bootstrap/glyphicons-halflings-regular.eot"
//= depend_on_asset "bootstrap/glyphicons-halflings-regular.svg"
//= depend_on_asset "bootstrap/glyphicons-halflings-regular.ttf"
//= depend_on_asset "bootstrap/glyphicons-halflings-regular.woff"

@import bootstrap

前述のエラーでお困りの方はお試しあれ。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?