10

この問題でbootstrap-sass-railsを使用しています.Railsプロジェクトを本番モードで実行すると、3x 404エラーが発生します:

GET http://localhost:3000/assets/twitter/bootstrap/glyphicons-halflings-regular.woff 404 (Not Found) assets/twitter/bootstrap/glyphicons-halflings-regular.woff:1
GET http://localhost:3000/assets/twitter/bootstrap/glyphicons-halflings-regular.ttf 404 (Not Found) assets/twitter/bootstrap/glyphicons-halflings-regular.ttf:1
GET http://localhost:3000/assets/twitter/bootstrap/glyphicons-halflings-regular.svg 404 (Not Found) 

rake assets:precompile RAILS_ENV=production を使用して、結果の静的ファイルを生成しました。

I, [2013-11-07T16:52:25.269370 #12948]  INFO -- : Writing myproject/public/assets/application-3517eb39b597107b3dbccbcbf4f0b3cc.js
I, [2013-11-07T16:52:25.315358 #12948]  INFO -- : Writing myproject/public/assets/application-1459bfe79a6477170658d53257e4a8fd.css
I, [2013-11-07T16:52:25.334356 #12948]  INFO -- : Writing myproject/public/assets/twitter/bootstrap/glyphicons-halflings-regular-8b1bdc16b9e098d67afebbf8d59fcea7.eot
I, [2013-11-07T16:52:25.345360 #12948]  INFO -- : Writing myproject/public/assets/twitter/bootstrap/glyphicons-halflings-regular-8d8305e5b6a807076d3ec68e2f190674.svg
I, [2013-11-07T16:52:25.357360 #12948]  INFO -- : Writing myproject/public/assets/twitter/bootstrap/glyphicons-halflings-regular-946071b70245967633bb3a774c60f3a3.ttf
I, [2013-11-07T16:52:25.367360 #12948]  INFO -- : Writing myproject/public/assets/twitter/bootstrap/glyphicons-halflings-regular-d7e2274ad1d940a0b2ce7480810ab223.woff
etc ...

これらの 3 つのフォント ファイルを除いて、すべてのアセットは正常に動作しています。一日中探しましたが、何も見つかりませんでした。Railsはこれら3つのファイルのハッシュなしのバージョンを探しているようですが、rakeはハッシュ付きでそれらを生成します

私のconfig/production.rb:

  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.assets.digest = true
  config.assets.version = '1.0'
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify

編集

@font-face 変数をオーバーライドしようとしましたが、古い変数が削除されていないようです:

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

グリフィコンをロードしましたが、まだ 3x 404 エラーが発生します。

4

4 に答える 4

3

私も同じ問題を抱えていました。inside@import "bootstrap-sprockets"に加えて追加する必要があることがわかりました。@import "bootstrap"application.css.sass

于 2014-07-25T14:40:16.073 に答える
2

Web サーバーに MIME タイプを追加します。

woff ファイルの提供方法を​​定義する必要があります。

IIS の場合は、IIS に移動して MINE タイプ ウィンドウを開きます

[追加] をクリックし、最初の入力ボックスに「 woff 」と入力し、2 番目のボックスに「 application/x-font-woff 」と入力します

次に、他の拡張機能について繰り返します

幸運を

于 2014-05-07T02:00:31.407 に答える
1

フォント ディレクトリは、アセット ディレクトリとして自動的に認識されません。config.assets.paths << Rails.root.join("app", "assets", "fonts")ファイルに:を設定して、明示的に追加する必要がありapplication.rbます。

于 2013-11-08T13:46:58.503 に答える