简体   繁体   English

Rails image_path/url 辅助方法

[英]Rails image_path/url helper methods

I have an image in app/assets/images/portfolio/01-example.jpg我在app/assets/images/portfolio/01-example.jpg 中有一张图片

I'm not entirely sure on how to use the image_url or image_path helpers to display this image in the view.我不完全确定如何使用image_urlimage_path助手在视图中显示此图像。

Is it <%= image_path('01-example.jpg') %> ?<%= image_path('01-example.jpg') %>吗? If anyone could correct me with the correct syntax, I'd appreciate it!如果有人能用正确的语法纠正我,我将不胜感激!

Do you want to display it in an image tag, ie is your view html?你想在图像标签中显示它,即你的视图html吗?

Then it's然后就是

<%= image_tag('portfolio/01-example.jpg') %> <%= image_tag('portfolio/01-example.jpg') %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM