I’ve inherited a rails application that uses jquery
It has lots of javascript include in assets/javascripts, the application.js that requires all the other files including
//= require jquery
//= require jquery_ujs
That’s good and the javascript is working ok.
However I was also expecting to see
gem "jquery-rails"
in the Gemfile.
Question:
Is the gemfile entry only needed for initial generators like rails g jquery:install and is it ok to not include it if not using the generators – will the js still work?
The actual source of
jqueryandjquery_ujsis included inside the gem, so you will need to keep it. However, if you’re using the asset pipeline and precompile your assets, than the gem doesn’t need to be loaded after the precompilation. This means that it is safe to put the gem inside yourassetsgroup inside your Gemfile.If you don’t have jquery-rails inside your Gemfile at all, and it does still work, that means that the source of jquery is somewhere else inside your load path. You might want to check out
app/assets,lib/assetsandvendor/assets. This is okay, but it not necessary and it means that you won’t get updates automatically when doing a bundle update.