在本教程的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 stylesheetsHere 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 = trueand set the value to false
# Enable the asset pipeline config.assets.enabled = falseYou 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 :-)
更多推荐
发布评论