pawel7318
pawel7318

Reputation: 3593

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 ?

Upvotes: 0

Views: 174

Answers (1)

infused
infused

Reputation: 24337

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']

Upvotes: 1

Related Questions