I've got a problem with Rails 3.1 assets pipeline.
Assets are included twice in development:
<script src="/assets/main_new.js?body=1" type="text/javascript"></script>
<script src="/assets/pagenav.js?body=1" type="text/javascript"></script>
<script src="/assets/tours.controller.js?body=1" type="text/javascript"></script>
<script src="/assets/tours.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
Rails somehow compiles and includes application.js so all the scripts are included twice – as individual file and in application.js
Everything's fine with precompiled assets in production.
development.rb
config.assets.compress = false
config.assets.debug = true
production.rb
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress both stylesheets and JavaScripts
config.assets.compress = true
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :scss
config.assets.compile = false
config.assets.digest = true
application.rb
config.assets.enabled = true
Best Answer
Try adding the following to development.rb:
...and then clearing your browser cache (update based on comments)
The static assets refer to precompiled assets in public/assets, which is where
rake assets:precompile
puts them.What's happening is that anything that exists in public/assets will override anything in app/assets if you are serving them. So public/assets/application.js is being loaded when the js tag is intending to identifiy app/assets/application.js.