22
10

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.

Uncaught ReferenceError: $ is not defined【rails】

Last updated at Posted at 2018-05-29

jqueryはrequire_treeより前で読み込む

railsへjQueryを導入しようとしたところ、最初の$(function()でエラーが起きる。

$(function(){
//省略
})

//= require_tree .を最後に読み込むようにして解決👌

app/assets/javascripts/application.js
//
//= require jquery
//= require jquery_ujs
//= require rails-ujs
//= require_tree .
22
10
0

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
22
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?