外部ファイルの接続
assets.rb
.
.
.
Rails.application.config.assets.precompile += %w( *.js )
rake restart
読み込みたいHTMLファイルに書き込む
<%= javascript_include_tag "hogehoge.js" %>
これで成功か?
Sprockets::Rails::Helper::AssetNotPrecompiledError in *********
Showing /Users/***///app/views//*****.html.erb where line #6 raised:
Asset hogehoge.js
was not declared to be precompiled in production.
Declare links to your assets in app/assets/config/manifest.js
.
//= link hogehoge.js
and restart your server
//= link hogehoge.js
これをapp/assets/config/manifest.js
に入力すればいいのか。
これで成功した。
出典
感想
これで外部ファイルから読み込むことができた。
しかし
他の方法も知りたい。
scriptタグから外部ファイルを読み込むことができなかったからだ。