2017-05-18 44 views
5

在Rails 5.1中,如果我們使用asset_path作爲公用文件夾中的文件,則存在棄用警告。Rails 5.1:公用文件夾中的文件的url助手

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,但它不工作,有沒有幫手?

+0

我時,我引用外部資源相同的錯誤添加了此方法,即:aws或其他地方的圖像 –

+0

您找到的任何解決方案嗎? –

+0

否,仍然在等待 –

回答

0

所以我在助手/ application_helper.rb

module ApplicationHelper 
    def public_path(path) 
     "#{ Rails.env.development? ? 'http://localhost:3000/' : 'https://cdn.mysite.fr/' }#{ path }" 
    end 
end 

,然後我可以使用public_path('images/image.jpg')的意見