简体   繁体   中英

javascript_include_tag file is missing on the production environment ( 404 )

On the development environment (with therubyracer ) all works great. Now I set nginx + passenger to run my rails app for the production environment. All works fine except one (slides_index.js) file for which I get 404.

That file contains jQuery code which has to be run just on one page . To do so I use <%= javascript_include_tag "slides_index" %> on that page.

I run rake assets:precompile which created public/assets/application-1774b3421bf0b4433ea3628c1c5dce38.js . There is no any other .js file in the that path, especially no slides_index.js (that one is in app/assets/javascripts/ ).

It's quite obvious that if there's not slides_index.js in the public/assets/ path than I get 404 for it. The question is why it works fine with therubyracer (development environment) and how to fix it in a proper way ?

By default Rails only compiles application.js as a standalone file. You can add other files to be compiled in config/application.rb with config.assets.precompile , so add the slides_index :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM