Help us understand the problem. What is going on with this article?

rails5でjQueryを使う

More than 1 year has passed since last update.

rails5でjQueryを使う方法

rails5でjQueryを使うためには、

1.gemのインストール,
2.application.jsへの記述 
3.application.html.erbへの記述

の3つの作業が必要

1.gemのインストール

gemfileに gem "jquery-rails"を記述し、bundle install

gemfile
gem "jquery-rails"

2.application.jsファイルへの記述

app/assets/javasciript下にある、application.jsにjQueryを読み込ませるコードをかく
(必ずapplication.jsにかくこと。ほかのjsファイルではダメ!)

application.js
//= require jquery
//= require jquery_ujs

3.application.html.erb

application.html.erbのhead内に以下の記述をする(すでに書いてあったらそのままにする)
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

最後に

Qiita初投稿です。よろしくお願いします。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away