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

时间:2019-07-11 04:46:40

标签: ruby-on-rails sprockets

我正要在视图中添加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'

1 个答案:

答案 0 :(得分:0)

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

的东西很有趣