LoginSignup
22
16

More than 3 years have passed since last update.

Sprockets::Rails::Helper::AssetNotPrecompiled in が出てコケた

Last updated at Posted at 2019-10-13

環境

Rails 5.2.3

次のエラーが出た

ctionView::Template::Error (Asset `application.css` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.

  //= link application.css
and restart your server):
    4:     <title>hogehogeapp</title>
    5:     <%= csrf_meta_tags %>
    6:     <%= csp_meta_tag %>
    7:     <%= stylesheet_link_tag "application", :media => "all" %>
    8:   </head>
    9:   <body>
   10:     <nav class="navbar navbar-expand navbar-dark bg-success" >

app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__823627666839579830_70158635396840'

なので
assets.rbに追記して

config/initializers/assets.rb
#省略
Rails.application.config.assets.precompile += %w( application.css )
#省略

次のコマンドを実行

$rake assets:precompile

あとは

$rails s

で起動した。

完全にメモ、あとで気が向けば追記

おしまい

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