Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 图像未正确显示在导航栏中,rails?_Ruby On Rails_Twitter Bootstrap_Twitter Bootstrap 3 - Fatal编程技术网

Ruby on rails 图像未正确显示在导航栏中,rails?

Ruby on rails 图像未正确显示在导航栏中,rails?,ruby-on-rails,twitter-bootstrap,twitter-bootstrap-3,Ruby On Rails,Twitter Bootstrap,Twitter Bootstrap 3,我试图在导航栏的左侧添加一个徽标(也可以作为主页的链接),但是,它在框中仅显示为“?”。有关于修复这个的提示吗 这是导航栏的代码 <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#"> <img alt="Brand" src="/assets/images/1.png"> &

我试图在导航栏的左侧添加一个徽标(也可以作为主页的链接),但是,它在框中仅显示为“?”。有关于修复这个的提示吗

这是导航栏的代码

 <div class="container-fluid">
   <div class="navbar-header">
     <a class="navbar-brand" href="#">
       <img  alt="Brand"  src="/assets/images/1.png">
     </a>
   </div>
</div>


使用资产管道和
image\u标记
helper

# image location
# app/assets/images/1.png

# view
<%= image_tag("1.png", alt: "Brand") %>
这就是为什么您无法使用图像的相对路径!它不存在!需要考虑的是:Rails非常强大,具有大量非常有用的内置功能。让它来做重担吧

同样,值得一读本指南:

/assets/1-71eb0fe483901ef632b3136926dd70ce3954e7cb6e97baa1bd53d197c38653d0.png