在控制器中查看图像路径

查克雷什瓦尔·夏尔马

我的图片位于/app/assets/images/myfolder/a.png. 我想在 api 中返回图像 url。那么,如何在控制器中获取这条路径呢?我已经尝试过以下

ActionController::Base.helpers.image_path('myfolder/a.png')
ActionController::Base.helpers.asset_path('myfolder/a.png')
view_context.image_path('myfolder/a.png')

但没有一个工作。

Farhan Memon 医学博士

试试这个

ActionController::Base.helpers.image_url('myfolder/a.png')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章