gpt4 book ai didi

ruby-on-rails - rails 5.1 : url helper for files in public folder

转载 作者:行者123 更新时间:2023-12-03 15:26:51 24 4
gpt4 key购买 nike

在 Rails 5.1 中,如果我们对公用文件夹中的文件使用asset_path,则会出现弃用警告。
DEPRECATION WARNING: The asset "favicon.ico" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.

所以我尝试了public_asset_path ,但它不起作用,有 helper 吗?

最佳答案

如果想在没有 Assets 管道的情况下使用辅助方法,需要指定 skip_pipeline选项。

像这样。
image_path("user/favicon.png", skip_pipeline: true)
或者,如果想要为整个应用程序启用 Assets 回退,config.assets.unknown_asset_fallback可以设置为真。
见:http://guides.rubyonrails.org/asset_pipeline.html#raise-an-error-when-an-asset-is-not-found

关于ruby-on-rails - rails 5.1 : url helper for files in public folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44041444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com