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

railsでjavascriptが読み込まれないときに確認すべきこと

More than 1 year has passed since last update.

以下の3つのファイルを確認していく。

  • /app/views/application.html.erb

  • /app/javascripts/application.js

  • /config/initializers/assets.rb

/app/views/application.html.erb

<script src=""></script>はrailsでは以下のようにして書く。
必要なものが記載されているか。

    <%= javascript_include_tag('jquery-xxx.min') %>

/app/javascripts/application.js

jsファイルをアセットパイプラインで読み込むように設定してあるか。
以下の記載で/assets/javascripts/内の全てのjsファイルを読み込んでくれる。
//= require jqueryのように個別で記載することももちろん可能。

//= require_tree .

/config/initializers/assets.rb

アセットのプリコンパイル対象として、例として以下のようにjavascriptが読み込まれるようになっているか

Rails.application.config.assets.precompile += ['*.js','*.css']
Why do not you register as a user and use Qiita more conveniently?
  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