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



我正要在我的视图中添加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.png.这个名字很有趣index

最新更新