Ruby on rails Rails:一个图像正在加载,但是为什么其他图像没有加载?
我一直在通过youtube上的Dave Jones教程学习Ruby on Rails 4,但在第4课上我遇到了一个小障碍。从FreeHTML5模板导入模板时。。。当我将第一个顶部照片cowboyup.jpg从img标记更改为rails标记时,它可以工作,但底部的4个照片标记(ad125.jpg)不能工作。当我进入firefox进行测试时。我带着萤火虫来查看来源。img标签在源代码中,但firebug通知我无法加载图像。Ruby on rails Rails:一个图像正在加载,但是为什么其他图像没有加载?,ruby-on-rails,ruby,web,ruby-on-rails-4,Ruby On Rails,Ruby,Web,Ruby On Rails 4,我一直在通过youtube上的Dave Jones教程学习Ruby on Rails 4,但在第4课上我遇到了一个小障碍。从FreeHTML5模板导入模板时。。。当我将第一个顶部照片cowboyup.jpg从img标记更改为rails标记时,它可以工作,但底部的4个照片标记(ad125.jpg)不能工作。当我进入firefox进行测试时。我带着萤火虫来查看来源。img标签在源代码中,但firebug通知我无法加载图像。 这是到目前为止我的代码。 视图/layouts/application.
这是到目前为止我的代码。
视图/layouts/application.html.erb
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lecture</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div id="wrapper"><!-- #wrapper -->
<header><!-- header -->
<h1><a href="#">Cowboy Up</a></h1>
<h2>Where the buffalo roam</h2>
<%= image_tag "cowboyup.jpg", :size => "940x200", :alt => "Drews a Cowboy" %>
<!-- <img src="images/cowboyup.jpg" width="940" height="200" alt=""> --> <!-- header image -->
</header><!-- end of header -->
<nav><!-- top nav -->
<div class="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">The Ranch</a></li>
<li><a href="#">History</a></li>
<li><a href="">Vision</a></li>
</ul>
</li>
<li><a href="#">Products</a>
<ul>
<li><a href="#">Spurs</a></li>
<li><a href="#">Chaps</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Rodeos</a></li>
<li><a href="#">Wrangling</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</nav><!-- end of top nav -->
<section id="main"><!-- #main content and sidebar area -->
<section id="container"><!-- #container -->
<section id="content"><!-- #content -->
<%= yield %>
</section><!-- end of #content -->
</section><!-- end of #container -->
<aside id="sidebar"><!-- sidebar -->
<h3>Things To Do</h3>
<ul>
<li><a href="#">Play Games</a></li>
<li><a href="#">Chat With Friends</a></li>
<li><a href="#">Swap Stories</a></li>
<li><a href="#">Sell Stuff</a></li>
<li><a href="#">Buy Stuff</a></li>
<li><a href="#">Trade Stuff</a></li>
</ul>
<h3>Our Sponsors</h3>
<%= image_tag "ad125.jpg"%> <%= image_tag "ad125.jpg"%><br/>
<%= image_tag "ad125.jpg"%> <%= image_tag "ad125.jpg"%><br/><br/>
<!-- <img src="images/ad125.jpg" alt="" /> <img src="images/ad125.jpg" alt="" /><br /> -->
<!-- <img src="images/ad125.jpg" alt="" /> <img src="images/ad125.jpg" alt="" /><br /><br /> -->
<h3>Connect With Us</h3>
<ul>
<li><a href="#">Twitter</a></li>
<li><a href="#">Facebook</a></li>
</ul>
</aside><!-- end of sidebar -->
</section><!-- end of #main content and sidebar-->
<footer>
<section id="footer-area">
<section id="footer-outer-block">
<aside id="first" class="footer-segment">
<h3>Blogroll</h3>
<ul>
<li><a href="#">one linkylink</a></li>
<li><a href="#">two linkylinks</a></li>
<li><a href="#">three linkylinks</a></li>
<li><a href="#">four linkylinks</a></li>
<li><a href="#">five linkylinks</a></li>
</ul>
</aside><!-- end of #first footer segment -->
<aside id="second" class="footer-segment">
<h3>Awesome Stuff</h3>
<ul>
<li><a href="#">one linkylink</a></li>
<li><a href="#">two linkylinks</a></li>
<li><a href="#">three linkylinks</a></li>
<li><a href="#">four linkylinks</a></li>
<li><a href="#">five linkylinks</a></li>
</ul>
</aside><!-- end of #second footer segment -->
<aside id="third" class="footer-segment">
<h3>Coolness</h3>
<ul>
<li><a href="#">one linkylink</a></li>
<li><a href="#">two linkylinks</a></li>
<li><a href="#">three linkylinks</a></li>
<li><a href="#">four linkylinks</a></li>
<li><a href="#">five linkylinks</a></li>
</ul>
</aside><!-- end of #third footer segment -->
<aside id="fourth" class="footer-segment">
<h3>Blahdyblah</h3>
<p>Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum.</p>
</aside><!-- end of #fourth footer segment -->
</section><!-- end of #footer-outer-block -->
</section><!-- end of #footer-area -->
</footer>
</div><!-- #wrapper -->
<!-- Free template created by http://freehtml5templates.com -->
</body>
</html>
class SayController < ApplicationController
def Hello
end
def goodbye
end
def something
end
end
<h1>Say#Hello</h1>
<p>Find me in app/views/say/Hello.html.erb</p>
test
<br/>
<%= link_to "Teach Drew", drew_teach_path%>
您的
图像
是否位于资产/图像
右侧?对于第一张照片,您在名称前加上路径前缀。最后两个似乎忽略了这一点。虽然只有当它们不在资产/图像中时才有必要这样做,但我已经解决了问题。显然,adblock plus不喜欢文件名ad125.jpg。当我更改文件名时,照片出现了。事实证明这很有趣。
Started GET "/say/Hello" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
Processing by SayController#Hello as HTML
Rendered say/Hello.html.erb within layouts/application (0.0ms)
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Completed 200 OK in 9ms (Views: 8.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/drew.css?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/print.css?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/say.css?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
Started GET "/assets/styles.css?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/drew.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
Started GET "/assets/say.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/assets/cowboyup.jpg" for 127.0.0.1 at 2014-06-14 05:23:36 -0700
[2014-06-14 05:23:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true