Rails Dispatch

Rails news delivered fresh

Presented by Engine Yard

View Question

Vote on questions you’d like to see answered by the expert contributors

Signup to ask questions or vote for the questions you’d like to see answered.

How do I set up rails 3 to use jquery instead of prototype, ideally so the default javascript tag references jquery?

Asked May 05, 2010
Yehuda Katz answered

You need to do two things. First, remove the default JavaScript files from public/javascripts and replace them with jquery.js from http://code.jquery.com/jquery-1.4.2.min.js (as jquery.js) and rails.js from http://github.com/rails/jquery-ujs/raw/59dd91d945570391f905b1e40444e5921dbc2b8f/src/rails.js.

Next, do the following in an initializer

module ActionView::Helpers
  JAVASCRIPT_DEFAULT_SOURCES = %w(jquery.js rails.js)

Answered May 09, 2010