问题
I have installed gem jquery-rails
in Rails 3.1 app. But line below
rails generate jquery:install --ui
Getting error:
Could not find generator jquery:install.
回答1:
In rails 3.1, because jquery is the default, you no longer need to install it, it will be required in app/assets/jquery/application.js and it will look something like:
//= require jquery
//= require jquery_ujs
//= require_tree .
You can verify which generators are available by executing rails g without anything else:
rails g
回答2:
for Rails 3.0.x application do the below steps,
Add gem “jquery-rails”, “~> 1.0.13″ in your Gemfile, and run bundle install
run the command rails generate jquery:install --ui --force, it will remove prototype.js, effects.js, dragdrop.js, controls.js and create jquery.js, jquery.min.js, jquery-ui.js, jquery-ui.min.js, jquery_ujs.js
to use jquery functions add the below lines in the application.js
//= require jquery
//= require jquery_ujs
来源:https://stackoverflow.com/questions/7103437/jqueryinstall-doesnt-work-in-rails