Heroku 找不到我的一些 rails 资产
Heroku can't find some of my rails assets
我是网络开发的新手,我一直在开发一个简单的应用程序以供学习。我已经能够从我的本地计算机部署到 Heroku,但由于某种原因,我用于某些矢量图像的自定义 类 无法在 Heroku 上呈现。
This is my page, 正如您所看到的,只有正方形应该有不同的图像。查看检查器,您会看到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) - https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.woff
Failed to load resource: the server responded with a status of 404 (Not Found) https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.ttf
我已尝试重新编译资产、重新提交并推送到 Heroku,但此错误仍然存在。奇怪的是,如果我使用 Heroku Bash 并查看 Heroku 文件目录,看起来文件在那里:
但是他们仍然在检查器中抛出那个错误。我的 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.compile = true
config.assets.js_compressor = :uglifier
知道是什么导致了这个资产问题吗?我正在使用 Rails 4.2.0。
通读 this link. 后我能够回答我自己的问题 本质上,我将字体文件从我的 CSS 目录中移出并移到了 app/assets 下它们自己的字体目录中目录,然后在 production.rb 中将以下行添加到应用程序 class:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
很快!有效。我没有在 CSS 中乱用 @font-face,因为我从平面图标中使用的资产是通过在 span 或 div 块中使用的自定义 classes 构建的。
我是网络开发的新手,我一直在开发一个简单的应用程序以供学习。我已经能够从我的本地计算机部署到 Heroku,但由于某种原因,我用于某些矢量图像的自定义 类 无法在 Heroku 上呈现。
This is my page, 正如您所看到的,只有正方形应该有不同的图像。查看检查器,您会看到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) - https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.woff
Failed to load resource: the server responded with a status of 404 (Not Found) https://enigmatic-hollows-2702.herokuapp.com/assets/flaticon.ttf
我已尝试重新编译资产、重新提交并推送到 Heroku,但此错误仍然存在。奇怪的是,如果我使用 Heroku Bash 并查看 Heroku 文件目录,看起来文件在那里:
但是他们仍然在检查器中抛出那个错误。我的 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.compile = true
config.assets.js_compressor = :uglifier
知道是什么导致了这个资产问题吗?我正在使用 Rails 4.2.0。
通读 this link. 后我能够回答我自己的问题 本质上,我将字体文件从我的 CSS 目录中移出并移到了 app/assets 下它们自己的字体目录中目录,然后在 production.rb 中将以下行添加到应用程序 class:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
很快!有效。我没有在 CSS 中乱用 @font-face,因为我从平面图标中使用的资产是通过在 span 或 div 块中使用的自定义 classes 构建的。