开发错误:资产未声明为在生产中预编译

Error in development: Asset was not declared to be precompiled in production

我正要在我的视图中添加 index.png,但遇到了这个错误。我把文件放在 app/assets/images/index.png

Sprockets::Rails::Helper::AssetNotPrecompiled in Maps#new

Showing /home/sumin/sumin/project/tourism-board/app/views/maps/new.html.slim where line #9 raised:

Asset was not declared to be precompiled in production.
Add `Rails.application.config.assets.precompile += %w( index.png )` to `config/initializers/assets.rb` and restart your server

Extracted source (around line #33):
      url_for establishment.avatar.variant(resize: ' 10x10 ')
    else
      image_url 'index.png'
    end
  end
end

Rails.root: /home/sumin/sumin/project/tourism-board
Application Trace | Framework Trace | Full Trace

app/helpers/application_helper.rb:33:in `establishment_marker_url'
app/views/maps/new.html.slim:9:in `block in _app_views_maps_new_html_slim___2128975323729843504_70193639517680'
app/views/maps/new.html.slim:7:in `map'
app/views/maps/new.html.slim:7:in `_app_views_maps_new_html_slim___2128975323729843504_70193639517680'

我不知道为什么,但我通过将资产名称从 index.png 更改为 marker.png 解决了这个问题。我认为不应该是index.pngindex

这个名字很有趣