开发者

Rails: Get the image src only

开发者 https://www.devze.com 2023-01-07 18:06 出处:网络
Does rails have a way to get JUST the src o开发者_运维知识库f an image as a string? I\'m trying to embed the image on a third party site in javascript.

Does rails have a way to get JUST the src o开发者_运维知识库f an image as a string? I'm trying to embed the image on a third party site in javascript.

This is the general idea (widget.js.erb):

var widgetImage = new Image();
widgetImage.src = "<=% Some groovy ruby code to just get the image src as a string %>"

Any ideas?


Yup, you're looking for image_path

image_path('something.png')
0

精彩评论

暂无评论...
验证码 换一张
取 消