ruby-on-rails – Rails图像消失,出现错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rails图像消失,出现错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
基本上我的问题是页面加载正常并且看起来正常.大约30秒后它突然消失了.

这是错误之前的服务器日志(加载页面时):

Started GET "/" for 127.0.0.1 at 2014-03-11 23:53:30 -0400
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb within layouts/application (0.7ms)
  Rendered layouts/_head.erb (3.3ms)
  Rendered layouts/_header.erb (0.9ms)
  Rendered layouts/_footer.erb (0.2ms)
Completed 200 OK in 11ms (Views: 10.5ms)

Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/taylor.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/wide.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/enchanted_large.png" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/sad.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

然后突然图像因客户端错误而消失(在Chrome的开发控制台中看到):

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
  http://localhost:3000/assets/taylor.jpg

而日志的唯一补充是:

Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:54:00 -0400

在看起来不错的30秒内,镀铬有一个装载符号,其中有图标

我的HTML在这一点上相当简单:

<div class="home-images">
  <%= image_tag "taylor.jpg",class: "home-image" %>
  <%= image_tag "wide.jpg",class: "home-image hide" %>
  <%= image_tag "sad.jpg",class: "home-image hide" %>
</div>

我甚至完全拿出了我的javascript.我也试过自己去掉turbolinks.它只发生在一个图像上.我不明白为什么……

当我切换html时,它是同一个图像(泰勒)给出了错误

<div class="home-images">
  <%= image_tag "wide.jpg",class: "home-image" %>
  <%= image_tag "taylor.jpg",class: "home-image hide" %>
</div>

我的所有图片都位于我的app / assets / images文件夹中

我的标题看起来像这样:

<head>
  <Meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title>Enchanting Events and Design</title>
  <%= favicon_link_tag       "favicon.ico" %>
  <%= stylesheet_link_tag  "application" %>
  <%= javascript_include_tag  "application" %>
  <%= csrf_Meta_tags %>
</head>

解决方法

当我使用mv命令替换图像时,我遇到了这个问题.这使得时间戳保持不变,因此打破了资产缓存.只需触摸受影响的文件即可修复它.
原文链接:https://www.f2er.com/ruby/269641.html

猜你在找的Ruby相关文章