Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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
Ruby on rails 带有内嵌样式的Rails Haml_Ruby On Rails_Ruby_Haml - Fatal编程技术网

Ruby on rails 带有内嵌样式的Rails Haml

Ruby on rails 带有内嵌样式的Rails Haml,ruby-on-rails,ruby,haml,Ruby On Rails,Ruby,Haml,如何在haml中为具有对象url的反向图像分配内联样式?英雄联盟 这是没有对象的div的工作版本 .main-image{style: "background-image: url('http://example.com/image.jpg');"} 但当我尝试这个: .main-image{style: "background-image: url(= @photos[0].image.url);"} 当我添加@photos[0].image.url时,它不起作用,有什么想法吗?您尝试过字

如何在haml中为具有对象url的反向图像分配内联样式?英雄联盟 这是没有对象的div的工作版本

.main-image{style: "background-image: url('http://example.com/image.jpg');"}
但当我尝试这个:

.main-image{style: "background-image: url(= @photos[0].image.url);"}

当我添加@photos[0].image.url时,它不起作用,有什么想法吗?

您尝试过字符串插值吗:

.main-image{style: "background-image: url(#{@photos[0].image.url});"}
.main-image{style: "background-image: url(#{@photos[0].image.url});"}

您是否尝试过字符串插值:

.main-image{style: "background-image: url(#{@photos[0].image.url});"}
.main-image{style: "background-image: url(#{@photos[0].image.url});"}

应插入此值,而不是直接将其写入字符串:


应插入此值,而不是直接将其写入字符串: