Up until yesterday jQuery was loading just fine in my Rails app. I was playing around with getting the debugger/ruby-debug gem installed. As you are probably aware there are issues with the debugger gem in Rails 3 and I was unsuccessful in getting the dependancies installe so I removed the gems from my Gemfile. Since then when loading my site jQuery is not loading. These are the messages I see in console:
assets/jquery_ujs.js?body=1:377Uncaught ReferenceError: jQuery is not defined
bootstrap-transition.js:24Uncaught TypeError: undefined is not a function
bootstrap.js:3Uncaught ReferenceError: jQuery is not defined
welcome:210Uncaught ReferenceError: $ is not defined
And here is my application.js file:
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .
If I load jQuery explicitly in layouts/application.html.erb, like so, it works:
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" %>
<%= javascript_include_tag "application" %>
Any thoughts on what I can do to resolve this and get jQuery loading again? Looking in .rvm/gems/ruby-1.9.3-p125/gems/jquery-rails-2.0.2/vendor/assets/javascripts I can see jquery.js and jquery.min.js are still there.
Thanks @Djj. Re-ordering my application.js tree seems to have resolved the issue. Here is my revised tree:
//= require jquery_ujs
//= require jquery
//= require twitter/bootstrap
//= require jquery.placeholder
//= require_tree .
In my case the problem was due to asynchronously loading the javascript file.
<%= javascript_include_tag "application", :async => true %>
Switching back to
<%= javascript_include_tag "application" %>
solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With