0

I have put all my javascript and css files in /assets/javascripts and /assets/stylesheets directories.

Example: /assets/javascripts/common.js

I load them in view file as follows:

<script type="text/javascript" src="/assets/common.js"></script>

I ran my rails app locally and it ran successfully. But on production machine, I getting the following error:

GET http://server-machine:port/javascripts/common.js 404 (Not Found) 
user3156792
  • 79
  • 1
  • 7
  • Possible dupicate http://stackoverflow.com/questions/10177843/rails-3-javascript-is-not-found-when-running-in-production – Siva Feb 25 '14 at 07:14

1 Answers1

0

Rails configuration is different between development and production. In production, assets are looked up from your public directory. Read up here to know how to compile your assets to make it ready for production.

From the docs:

In production, Rails precompiles these files to public/assets by default. The precompiled copies are then served as static assets by the web server. The files in app/assets are never served directly in production.

Raj
  • 22,346
  • 14
  • 99
  • 142