0
0

More than 3 years have passed since last update.

Sprockets::Rails::Helper::AssetNotPrecompiled in *** が出たので解消法をメモ

Last updated at Posted at 2021-03-22

■環境
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
Rails 6.0.3.5

■状況
①viewからCSSを読み込むため、headタグに以下を追記
<%= stylesheet_link_tag 'index', media: 'all', 'data-turbolinks-track': 'reload' %>

②app/assets/stylesheets/ディレクトリにindex.cssファイルを手動で生成
③ビューファイルを開くと「Sprockets::Rails::Helper::AssetNotPrecompiled in ***」というエラーが出る。

■対処法
①config/initializers/assets.rbファイルに以下を追記
Rails.application.config.assets.precompile += %w( index.css )

②サーバを再起動(ctrl+C → rails s)

★2021/03/22ここまで

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