在ROR教程中,rails无法找到CSS文件(custom.css和blueprint)或logo.png(In the ROR Tutorial, rails can't find CSS

编程入门 行业动态 更新时间:2024-10-27 04:35:09
在ROR教程中,rails无法找到CSS文件(custom.css和blueprint)或logo.png(In the ROR Tutorial, rails can't find CSS files (custom.css & blueprint) or logo.png)

在本教程的5.1节中,Rails似乎无法找到CSS文件(custom.css或blueprint文件)或logo.png。 我已经对代码进行了三重检查,它与git存储库中的内容完全相同。

我还阅读了资产管道指南 ,所有默认值都是正确的。

我百分百肯定它与资产管道有关,但我似乎无法弄明白。

在此先感谢您的帮助。

这是我的公共目录列表:

$ ls public/images public/stylesheets public/images: logo.png public/stylesheets: blueprint/ custom.cssls images stylesheets

以下是我得到的错误:

Started GET "/assets/custom.css" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /custom.css - 404 Not Found (14ms) Started GET "/assets/blueprint/screen.css" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /blueprint/screen.css - 404 Not Found (2ms) Started GET "/assets/logo.png" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /logo.png - 404 Not Found (3ms)

In section 5.1 of the tutorial, Rails can't seem to find the CSS file (custom.css or the blueprint files) or logo.png. I have triple-checked the code and it's identical to what is in the git repository.

I have also read the asset pipeline guide and all the default values are correct.

I am a 100% sure that it has something to do with the asset pipeline, but I can't seem to figure it out.

Thanks in advance for your help.

Here is a listing of my public directory:

$ ls public/images public/stylesheets public/images: logo.png public/stylesheets: blueprint/ custom.cssls images stylesheets

Here are the errors that I'm getting:

Started GET "/assets/custom.css" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /custom.css - 404 Not Found (14ms) Started GET "/assets/blueprint/screen.css" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /blueprint/screen.css - 404 Not Found (2ms) Started GET "/assets/logo.png" for 127.0.0.1 at 2011-12-15 14:23:20 -0800 Served asset /logo.png - 404 Not Found (3ms)

最满意答案

我认为Emily指向正确的方向,应用程序正在寻找assets-folder中的图像,而不是公共文件夹中的图像。 我建议您不要将其移出公共文件夹,只要您正在处理教程,就会禁用资产管道(这样您就可以按照教程编写)。

要实现此目的,请进入config/application.rb -file并查看以下行:

# Enable the asset pipeline config.assets.enabled = true

并将值设置为false

# Enable the asset pipeline config.assets.enabled = false

您还必须从Gemfile中删除/注释掉sass-rails 。

之后重新启动服务器,它应该按预期工作。

一旦你完成了教程,你应该考虑在资产管道周围弯曲,因为它的好处是值得的:-)

I think Emily is pointing you in the right direction, the application is looking for the images in assets-folder, not in the public-folder. Instead of moving it out of the public folder, I would recommend to disable the asset-pipeline as long as you are dealing with the tutorial (just so you can follow the tutorial as written).

To achieve this, go into your config/application.rb-file and look out for the following line:

# Enable the asset pipeline config.assets.enabled = true

and set the value to false

# Enable the asset pipeline config.assets.enabled = false

You will also have to remove/comment out sass-rails from your Gemfile.

After that restart your server and it should work as expected.

Once you have finished the tutorial, you should consider bending your head around the asset-pipeline, since the benefits out of it are worth the while :-)

更多推荐

本文发布于:2023-07-22 02:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1216005.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   教程   custom   CSS   ROR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!