Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css Rails背景图像不显示?_Css_Ruby On Rails_Sass - Fatal编程技术网

Css Rails背景图像不显示?

Css Rails背景图像不显示?,css,ruby-on-rails,sass,Css,Ruby On Rails,Sass,在我的rails应用程序文件中:application.scss,我设置如下:(我希望backtest.png显示在任何页面中。) 在login.html.erb中,我想显示另一幅图像: body { background-image: url('/assets/iot.png'); width: 100%; height: 100%; } 在本地,我使用rails服务器来显示,这很好,但是当我上传到Nginx时,backtest.png仍然可以,但是i

在我的rails应用程序文件中:
application.scss
,我设置如下:(我希望
backtest.png
显示在任何页面中。)

login.html.erb
中,我想显示另一幅图像:

body {
      background-image: url('/assets/iot.png');
      width: 100%;
      height: 100%;
  }
在本地,我使用rails服务器来显示,这很好,但是当我上传到Nginx时,
backtest.png
仍然可以,但是
iot.png
不显示,甚至不显示
backtest.png
,只是白色背景?我怎样才能解决这个问题

每当我推出新版本时,我都要做
assets:clean
assets:precompile

config/deploy/environments/production.rb:

config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true

已尝试将两个图像都更改为
背景图像:url
,并且两个图像未显示,已尝试
背景图像:url('/assets/iot.png')
图像url
,但它在
.erb

上不起作用。您可以在
login.html.erb
中使用
资产路径
帮助程序作为ruby注入:

background-image: url('<%= asset_path 'iot.png' %>');
背景图像:url(“”);

它的url不是image-url。您使用了
背景图像:图像url(“backtest.png”)
url
替换
image-url
我在本地尝试过,但在Nginx制作中,两张图片没有显示!这是一个Ruby on Rails应用程序,
image-url()
是Sass的一个资产助手,它被编译成
url()
。但是我不能在login.html.erb中使用background-image:image-url,只能使用background-image:url,怎么办?
background-image: url('<%= asset_path 'iot.png' %>');