【问题标题】:Error in development: Asset was not declared to be precompiled in production开发中的错误:资产未声明为在生产中预编译
【发布时间】:2019-11-20 17:37:05
【问题描述】:

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

【问题讨论】:

    标签: ruby-on-rails sprockets


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 2016-03-24
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多