image_tag 对同一路径给出不同的结果

image_tag gives different result for the same path

基本上我有

= image_tag('procedure_icons/chemical/chemical.png')

给出预期结果,正确html

<img src="/assets/procedure_icons/chemical/chemical-7eee22622b56126c0339a1c340bd4708ca689031ea6448a132c5c004beb32e78.png" alt="Chemical">

但是当我尝试这样的事情时

= image_tag(object.icon_path)

其中 icon_path 是 draper 装饰器方法

def icon_path
  "/procedure_icons/#{object.icon_type}/#{object.icon_type}.png"
end

生成的html不同

<img src="/procedure_icons/chemical/chemical.png" alt="Chemical">

谁能解释一下?

正在传递资产管道可以识别的第一个 image_tag 'procedure_icons/chemical/chemical.png',因此源是资产管道处理的图像。

正在传递第二个 image_tag '/procedure_icons/chemical/chemical.png',它只是告诉 rails 使用传递给助手的特定路径(注意前面的反斜杠)