How to swap jquery for prototype in Rails 3.1

2019-05-19 07:12发布

问题:

I have a rails 3.1 project that was created with the default jQuery. What is the best way to convert the project to use prototype instead?

回答1:

  1. Remove the jquery gem from Gemfile
  2. add prototype-rails to it

From https://github.com/rails/prototype-rails:

You may want to add them to your app/assets/javascripts/application.js:

//= require prototype
//= require prototype_ujs
//= require effects
//= require dragdrop
//= require controls

New applications using this may also want to add

config.action_view.debug_rjs = true

to their config/environments/development.rb.



回答2:

diodeus is right, i'd rewrite it, and take it as a great opportunity to improve the code ;) nevertheless i'm curious, why would you wanna switch TO prototype