1
1

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 3 years have passed since last update.

JS(rails)で404 (Not Found)が出た時の一時対処法

Posted at

クイズアプリを作成してる時にJSをrailsで読み込もうとしても404 (Not Found)が出て、読み込まれない時の話。

結論

assets/views/index.html.erb
<%= javascript_include_tag 'fuga.js' %>

さらに

config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( fuga.js )

で再起動して表示はできるようになりました。
 
404 (Not Found)が出るときは基本的にrails側がJSを読み込めていないよということのようなので、
アセットパイプラインに個別で表示して欲しい内容を記載、というか追加することでそれを個別で読み込んでくれるようになったようです。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?