[英]Missing assets on production mode - passenger on nginx
When i move to production many assets are missing. 当我开始生产时,很多资产都丢失了。 There is no background image but there are styles for background from css.
没有背景图片,但是有来自CSS的背景样式。 Many JS doesn't load ..
许多JS无法加载..
I put in config production.rb : 我把config production.rb:
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
In application.rb : 在application.rb中:
config.assets.precompile += %w( ie.css )
config.assets.paths << "#{Rails.root}/app/assets/fonts"
but fonts doesnt load. 但字体不会加载。 I see in public/assets all fonts but there isnt any on my site.
我在公共/资产中看到了所有字体,但是我的网站上没有任何字体。
Can someone write answer - how config application to work on production ? 有人可以写答案-配置应用程序如何在生产环境中工作吗? Why i have xxx.jpg from css file but havent got yyy.jpg from that same css file..
为什么我从css文件中获取xxx.jpg但没有从同一css文件中获取yyy.jpg。
CSS for background: 背景的CSS:
body{
line-height: 1;
background: #fff url('wallpaper.jpg') top left;
IMAGES location - assets/images 图像位置-资产/图像
FONTS location - assets/fonts 字体位置-资产/字体
Sometimes in chrome console i see : 有时在Chrome控制台中,我看到:
GET ..../assets/wallpaper.jpg 404 (Not Found) xxxxxx/:11
GET...../assets/main_page.png 404 (Not Found) xxxxxx/:30
GET ...../assets/fonts/Lato-Bol.ttf 404 (Not Found)
and sometimes not, but always there is no fonts and many assets. 有时不是,但是总是没有字体和很多资产。
My application css: 我的应用程序CSS:
*= require_self
*= require chosen
*= require fancybox
*= require page
*= require_tree .
*/
Try using image-url
instead of url
. 尝试使用
image-url
而不是url
。
background: #fff image-url('wallpaper.jpg') top left;
From the Asset Pipeline documentation : 从资产管道文档中 :
When using the asset pipeline, paths to assets must be re-written and sass-rails provides -url and -path helpers (hyphenated in Sass, underscored in Ruby) for the following asset classes: image, font, video, audio, JavaScript and stylesheet.
使用资产管道时,必须重新编写资产路径,并且sass-rails为以下资产类别提供-url和-path帮助器(在Sass中带连字符,在Ruby中加划线):图像,字体,视频,音频,JavaScript和样式表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.