In a previous post I talked about using jQuery and modifying the rails.js file to fit your needs doing deletion. Recently I figured out a much better way to do this. You can install a gem then run a rails generate command which will delete your current javascript files and replace them with the appropriate jQuery files.
Step 1: Install “jquery-rails” Gem
In command line type:
gem install jquery-rails
Or Add the following line to your gemfile project and run the “bundle install” command
gem ‘jquery-rails’
Step 2: Add jQuery to Project
Open up your project in command line and type:
rails generate jquery:install
If you want to use jQuery UI add –ui
rails generate jquery:install –ui
That is it. Fairly simple to do for more information about this gem visit the githup repo for it. jquery-ujs github repositor. I recommend adding the line to your gem file for doing the install. However, if you want to add jquery manually visit the github page for manual installation instructions.


{ 2 comments… read them below or add one }
Which version of Rails is this installation for?
Rails 3 is what I used it on. However, I have found you can pick and pull things out as needed if it doesn’t work quite right. I don’t know if it works for rails 2.*