Rails 3.1beta Sprockets 找到图像但图像不显示?

发布于 2024-11-09 17:43:21 字数 1255 浏览 3 评论 0原文

我不确定解释这个问题的最佳方式,我已经在 Windows 7 上安装了 Rails 3.1beta 和 Ruby 1.9.2,使用这些路由创建了一个新应用程序:

constraints :subdomain => 'admin' do

scope :module => "admin" do

  #resources :undo_items do
    #post 'undo', :on => :member
  #end

  #resources :projects, :domains, :emails, :databases, :admins, :services do
  resources :projects do
  end

  #match "projects" => "projects#index"
  #match "domains" => "domains#index"

  root :to => "projects#index"
end

end

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
root :to => 'admin/projects#index'

sass 的一个示例是:

div {

        h1 { width: 177px; height: 54px; 
             background: url("summit-logo.png") no-repeat;
             float:left; position: relative; top: 15px; 

             a { text-indent: -9999px; display: block; 
                 width: 100%; height: 100%; }

        }

当请求路由时:

Started GET "/assets/summit-logo.png" FOR 127.0.0.1 at 2011-05-23 09:26:12 +0100

[Sprockets] /summit-logo.png 9a3c3...rest of unique request... fresh

图像位于 app/assets/images/summit-logo.png

关于为什么 Sprockets 似乎找到它但没有显示的任何想法?

谢谢!

I am not sure the best way to explain this one, I have installed Rails 3.1beta with Ruby 1.9.2 on Windows 7, created a new app with these routes:

constraints :subdomain => 'admin' do

scope :module => "admin" do

  #resources :undo_items do
    #post 'undo', :on => :member
  #end

  #resources :projects, :domains, :emails, :databases, :admins, :services do
  resources :projects do
  end

  #match "projects" => "projects#index"
  #match "domains" => "domains#index"

  root :to => "projects#index"
end

end

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
root :to => 'admin/projects#index'

One example of the sass is:

div {

        h1 { width: 177px; height: 54px; 
             background: url("summit-logo.png") no-repeat;
             float:left; position: relative; top: 15px; 

             a { text-indent: -9999px; display: block; 
                 width: 100%; height: 100%; }

        }

When the route is requested:

Started GET "/assets/summit-logo.png" FOR 127.0.0.1 at 2011-05-23 09:26:12 +0100

[Sprockets] /summit-logo.png 9a3c3...rest of unique request... fresh

The image is under app/assets/images/summit-logo.png

Any ideas as to why Sprockets seems to find it but it is not being displayed?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

脱离于你 2024-11-16 17:43:21

这是 Sprockes 中的一个错误

其原因是,在 Windows 中,Sprockets 以文本模式读取图像,这会导致各种损坏。在几乎所有情况下,它都会导致发送的字节数少于 Content-length 标头中声明的字节数。在 Firefox 中,您实际上可以看到页面仍在加载大约 30 秒。这是浏览器等待丢失字节的时间。

看来这个问题很快就会得到解决: https://github.com/rails/rails/issues/第1207章

This is a bug in Sprockes

The reason for this is that in Windows Sprockets reads the images in text mode which results in all kinds of corruptions. In almost all cases it results in sending less bytes than declared in the Content-length header. In Firefox you can actually see that the page is still loading for about 30 seconds. That's the time the browser waits for the missing bytes.

It seems that this will be resolved soon: https://github.com/rails/rails/issues/1207

做个少女永远怀春 2024-11-16 17:43:21

我认为你应该在下面寻找它
网址(/assets/summit-logo.png)
但我觉得很奇怪,你没有得到 404。

在我的例子中,链轮(或管道中的其他人)以某种方式重新编码了我的图像,所以它们都扭曲了。好吧,测试版的麻烦...

I think you should look for it under
url(/assets/summit-logo.png)
but I think it's weird, that you do not get a 404.

In my case sprockets (or somebody else down the pipe) somehow re-encodes my images, so they get all distorted. Well, beta troubles...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文