2016-09-13 85 views
1

我想的是定製文件夾添加到資產的路徑:試圖自定義文件夾添加到資產路徑

module MyApp 
    class Application < Rails::Application 
    config.assets.paths << Rails.root.join("something....") 
    # .... 
    config.assets.paths << Rails.root.join("app", "my_folder1", "fonts") 

我重新啓動我的應用程序,當直接去http://localhost:3000/my_folder1/fonts/my_font1.ttfhttp://localhost:3000/my_folder1/my_font1.ttf在瀏覽器,我得到了error 404。爲什麼?如何解決它?請注意, 故意在文件夾「my_folder1」中。

回答

3

這不是您如何訪問資產管道。您的所有網址應以/assets/開頭,路徑爲文件路徑減去前導子目錄。

例如:app/assets/javascripts/test.js

http://example.com/assets/test.js 

在你的情況公開訪問,你應該看

http://example.com/assets/my_font1.ttf 
+0

你有什麼推薦的移動資產?一個單獨的文件夾「my_rails_project/app/mobile_assets」與正常的「資產」具有相同的結構嗎? – Johshi

相關問題