jquery:install doesn't work in Rails

烂漫一生 提交于 2019-12-24 03:30:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!