在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 …Run Code Online (Sandbox Code Playgroud) 目标:将我的rails应用程序与生产中的资产中的静态图像一起使用environemt
脚步:
RAILS_ENV=production rails assets:precompileRAILS_SERVE_STATIC_FILESenvironemt变量设置true为启用公共文件服务器(在production.rb-config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?config.serve_static_assets = true到
/config/application.rb通过此设置,我启动了服务器.
我有一些静态图像,/app/assets/images/其中带有指纹文件名的预编译版本现在/public/assets.例子:
aussen-d2fb0029a12281121a1752c599e715a8e2b3db17f1e8e18248a79a7b1ca63b91.jpghintergrund-ca80e1ae5a697c86898f3a7e107694a76dc12e54320b8ac80c58eecbffe0414a.png到目前为止这么棒.
当我background-image: url(<%= asset_path('hintergrund') %>);在application.css.erb其中使用它成功加载预编译的背景图像/public/assets.
问题:我无法在视图中使用image_tags访问预编译的图像!例:
<%= image_tag("aussen") %>
Run Code Online (Sandbox Code Playgroud)
错误日志:
I, [2018-03-23T00:46:29.133381 #9289] INFO -- : [f36ff000-6261-4c2c-bfcc-4a2f80cae682] Started GET "/" for 46.142.136.81 at 2018-03-23 00:46:29 +0100
I, [2018-03-23T00:46:29.134466 #9289] INFO -- : [f36ff000-6261-4c2c-bfcc-4a2f80cae682] Processing by HomeController#index as HTML
I, [2018-03-23T00:46:29.136604 #9289] INFO …Run Code Online (Sandbox Code Playgroud)