Reputation: 19723
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?
Upvotes: 2
Views: 159
Reputation: 4499
In your config/environments/development.rb try setting:
config.assets.debug = false
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.
Upvotes: 1