簡體   English   中英

生產環境中缺少javascript_include_tag文件(404)

[英]javascript_include_tag file is missing on the production environment ( 404 )

在開發環境(使用therubyracer )上,一切都很好。 現在,我將nginx + passenger設置為在生產環境中運行我的rails應用程序。 除了我得到404的一個(slides_index.js)文件外,其他所有文件都正常運行。

該文件包含必須在一頁上運行的 jQuery代碼。 為此,我在該頁<%= javascript_include_tag "slides_index" %>使用<%= javascript_include_tag "slides_index" %>

我運行rake assets:precompile創建了public/assets/application-1774b3421bf0b4433ea3628c1c5dce38.js 該路徑中沒有其他任何.js文件,尤其是沒有slides_index.js (該文件位於app/assets/javascripts/ )。

顯而易見,如果public/assets/路徑中沒有slides_index.js ,我會得到404。 問題是為什么它在therubyracer (開發環境)中可以正常工作,以及如何以適當的方式對其進行修復?

默認情況下,Rails僅將application.js編譯為獨立文件。 您可以使用config.assets.precompile在config / application.rb中添加要編譯的其他文件,因此添加slides_index

config.assets.precompile += ['slides_index.js']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM