In main.js, I have:
$(document).ready(
function(){
alert('foo');
});
app/assets/javascripts/application.js has:
//= require jquery
//= require jquery_ujs
//= require main
In development. After running rake assets:precompile, I refresh any page, it executes alert('foo') twice. It’s only supposed to do it once. It seems as if there are two copies of main.js being loaded.
Am I doing something wrong?
In your config/environments/development.rb try setting:
or just don’t precompile your assets in development. The js is likely executing twice in your development environment because you’ve precompiled the assets; consequently it’s now executing both the script in the original file AND the one you’ve precompiled.