资产管道中不存在资产"logo.png"

T.K*_*Kul 26 ruby-on-rails asset-pipeline ruby-on-rails-5.1

在Rails 5.1.3中,我在app/assets/images中更改徽标文件然后错误不知道要修复什么.谁知道?

The asset "logo.png" is not present in the asset pipeline.
Run Code Online (Sandbox Code Playgroud)

已经尝试重新启动rails,rails clean,rails或rails assets:precompile

这是我的config/initializers/assets.rb

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Run Code Online (Sandbox Code Playgroud)

小智 24

我遇到了类似的问题.解决方案是在图像上添加文件扩展名.

= image_tag 'logo', alt: ''
Run Code Online (Sandbox Code Playgroud)

= image_tag 'logo.jpg', alt: ''
Run Code Online (Sandbox Code Playgroud)


Sky*_*ter 18

因为它没有在这里发布...对我而言,它就像重新启动Rails服务器一样简单.

在此输入图像描述


T.K*_*Kul 5

这里我为解决问题所做的工作假设我的代码没有任何问题并且它有效:

  1. 使用以下命令清理 /tmp/assets 中的资源缓存:
$rake tmp:clear
Run Code Online (Sandbox Code Playgroud)

正如这里所说

  1. 使用以下命令再次预编译资产:
$rake assets:precompile
Run Code Online (Sandbox Code Playgroud)


小智 4

尝试这样做

首先去

app/assets/images
Run Code Online (Sandbox Code Playgroud)

第二个创建文件夹徽标

app/assets/images/logos
Run Code Online (Sandbox Code Playgroud)

第三步将图像添加到徽标中

app/assets/images/logos/logo.png
Run Code Online (Sandbox Code Playgroud)

最后在您的应用程序中放入此代码

<%= link_to image_tag("logos/logo.png"), root_path %>
Run Code Online (Sandbox Code Playgroud)

到处都会有工作