19
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RailsにjQueryをいれるときはrails g するんやで

Last updated at Posted at 2014-04-25

初歩的な内容だと思う。今日び珍しくrailsでjqueryつかったことなかったので知りませんでした。
Gemfileにjquery-railsはデフォで記載されていると思うけど、バージョン指定はないので、お好みでバージョンを指定しておく。

Gemfile
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'

(中略)

# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 3.1.0'
# Use jquery-UI as the JavaScript library
gem 'jquery-ui-rails', '~> 4.2.1'

Gemfileの編集が終わって、bundle update したら、rails g する。

$ rails g jquery:install  
	remove	public/javascripts/prototype.js
	remove	public/javascripts/effects.js 
	remove	public/javascripts/dragdrop.js
	remove	public/javascripts/controls.js
  	copying	jQuery (1.11.0)
	create	public/javascripts/jquery.js  
	create	public/javascripts/jquery.min.js 
  	copying	jQuery UJS adapter (f160fa)
	remove	public/javascripts/rails.js
	create	public/javascripts/jquery_ujs.js
19
19
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?