Difference between jquery-rails & jquery-ujs Difference between jquery-rails & jquery-ujs jquery jquery

Difference between jquery-rails & jquery-ujs


jquery-ujs is the unobtrusive implementation to allow you to use jQuery in a Rails app. Simply speaking, it's just a single rails.js. To use it, you have to get jQuery and setup your Rails app.

jquery-rails is the gem to do this for you, it bundles (in its own vendor/assets directory) the most recent jQuery, jQuery-UI and jquery-ujs lib. I suggest you use it directly.

Update: you can checkout the vendor/assets/javascripts directory here:

https://github.com/rails/jquery-rails/tree/master/vendor/assets/javascripts

Under it sit the most recent jquery, jquery-ui and jquery_ujs(identical to the rails.js in jquery-urj project).


jquery-rails is jquery + jquery UJS adapter.

jQuery we know its a javascript library. And Rails team included jquery-rails for avoiding extra work of the developers to includes jquery. I think they included jquery UJS adapter for sending CSRF tokens in rails while we are using an ajax request.

You remove the line

 //= require jquery_ujs 

and try to send ajax request to the server. You will get a WARNING:

 Can't verify CSRF token authenticity

If you are using devise may be it will automatically logs out from the session. Hope this helps.


you would like this a good demo on jrails and jquery-ujs