本文介绍了将图像添加到轨道上的ruby布局中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的模板中为我的ruby on rails项目添加一个图像,其中我当前拥有代码< img src =../../../ public / images /在布局 stores.html.erb 文件中rss.jpgalt =rss feed/> 然而这似乎不是加载,因为它看起来像错过了一条我不确定它应该是什么的路线。

I would like to add an image in my template for my ruby on rails project where i currenly have the code <img src="../../../public/images/rss.jpg" alt="rss feed" /> in a the layout stores.html.erb file however this doesn't seem to load as it looks like its missing a route which i'm not sure what its supposed to be.

有什么想法吗?

推荐答案

<$ c中的任何内容可以在根路径( / )访问$ c> public 文件夹,因此请将img标记更改为:

Anything in the public folder is accessible at the root path (/) so change your img tag to read:

<img src="/images/rss.jpg" alt="rss feed" />

如果你想使用rails标签,请使用:

If you wanted to use a rails tag, use this:

<%= image_tag("rss.jpg", :alt => "rss feed") %>

这篇关于将图像添加到轨道上的ruby布局中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 20:42