我使用Rails 5.2 ActiveStorage上传图片 . 上传成功后,我通过 <%= image_tag(rails_blob_path(@img.image) %>
获取图片网址,显示如下:
When I use <%= rails_blob_path(@img.image) %>, I get the :
“/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--f9f1af07604db61f5300fd8b9aa121498cb55e9b/002.jpeg”
When I use <%= @img.image.blob.filename %>, I get the filename:
“002.jpeg”
When I use <%= @img.image.attachment.record_type %>, I get the filename: "Img"
When I use <%= @img.image.attachment.record_id %>, I get the filename: "77"
But I just want to get the url just like :
“http://127.0.0.1:3000/# /# /#”,
例:
“http://127.0.0.1:3000/Img/77/002.jpeg”
我该怎么办才能得到想要的网址?非常感谢!