这是我定义文件名的方式。
class MySerializer < ActiveModel::Serializer
attributes :id,
:filename
def filename
object.filename
end
end
这是我在细长文件中使用它并用于段落的方式(即,它穿上我的弦)。
p
= "{{object.filename}}"
这就是我试图将其用作图像路径的方式,但不起作用。 (The asset "images/{{object.filename}}.svg" is not present in the asset pipeline.
)
i
= image_tag("images/" + "{{object.filename}}" + ".svg", size: 24x24)
我在做什么错?
据我所知,您使用的语法错误。
在rails中进行字符串插值的语法是:
p
= "#{object.filename}"
i
= image_tag("images/" + "#{object.filename}" + ".svg", size: 24x24)
Advice:
尝试粘贴您的错误,而不是"not working"
,"something's going wrong"
。它构成了一个更好的问题,但是如果没有它,问题将是不完整的。