jQuery! For Rails! So great.
This gem provides:
- jQuery 1.10.2
- the jQuery UJS adapter
- assert_select_jquery to test jQuery responses in Ruby tests
Starting with v2.1, the jquery-rails gem follows these version guidelines to provide more control over your app's jquery version from your Gemfile:
patch version bump = updates to jquery-ujs, jquery-rails, and patch-level updates to jquery minor version bump = minor-level updates to jquery major version bump = major-level updates to jquery and updates to rails which may be backwards-incompatible
See VERSIONS.md to see which versions of jquery-rails bundle which versions of jQuery.
Apps generated with Rails 3.1 or later include jquery-rails in the Gemfile by default. So just make a new app:
rails new myapp
If upgrading from an older version of rails, or for rails 3.0 apps, add the jquery-rails gem to your Gemfile.
bundle install. The rest of the installation depends on
whether the asset pipeline is being used.
Rails 3.1 or greater (with asset pipeline enabled)
The jquery and jquery-ujs files will be added to the asset pipeline and available for you to use. If they're not already in
//= require jquery //= require jquery_ujs
For jQuery UI, we recommend the jquery-ui-rails gem, as it includes the jquery-ui css and allows easier customization.
As of v3.0, jquery-rails no longer includes jQuery UI. Use the jquery-ui-rails gem above.
Rails 3.0 (or greater with asset pipeline disabled)
This gem adds a single generator:
jquery:install. Running the generator will remove any Prototype JS files you may happen to have, and copy jQuery and the jQuery-ujs driver for Rails to the
:defaults when Rails is run in
test mode (un-minified versions will be included when Rails is run in
To invoke the generator, run:
rails generate jquery:install
As of v3.0, jquery-rails no longer includes jQuery UI, you will need to install it by yourself as needed.
Feel free to open an issue ticket if you find something that could be improved. A couple notes:
If the jquery scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jquery scripts.
Many thanks are due to all of the jquery-rails contributors. Special thanks to JangoSteve for tirelessly answering questions and accepting patches, and the Rails Core Team for making jquery-rails an official part of Rails 3.1.
Copyright André Arko, released under the MIT License.