Ruby-on-rails rails 3.1 ActionController::RoutingError(没有路由匹配 [GET] "/assets/rails.png"):
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7106820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rails 3.1 ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
提问by Michael Durrant
Standard new rails app has issue showing the rails.png
标准的新 Rails 应用程序有问题显示 rails.png
ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself.
我尝试将 .png 文件移动到资产和资产/图像中的各个位置,以及较旧的“公共”或“公共/图像”位置并更改页面,但没有任何帮助。如果您已经看到并解决了这个问题,请回答。我自己尝试了大约 20 种不同的组合。
Version: 'rails', '3.1.0.rc4'
版本:'rails','3.1.0.rc4'
采纳答案by Michael Durrant
It must have been an rc4 issue as the final release didn't have this issue.
它一定是 rc4 问题,因为最终版本没有这个问题。
11/27/11 - I now wonder if this was just due to the asset pipeline that was introduced in rails 3.1, requiring therake assets:precompilecommand (compiles and copies images, css and js fromapp/assetstopublic/.
If anyone finds that to be the case, please add a comment!
2011 年 11 月 27 日 - 我现在想知道这是否只是由于在 rails 3.1 中引入的资产管道,需要rake assets:precompile命令(从app/assetsto编译和复制图像、css 和 jspublic/。
如果有人发现是这种情况,请添加评论!
回答by tybro0103
I just had a problem throwing a similar error. In my case I was starting the rails server in production mode in Mac OSX using the standard WEBrick. It threw this error because of the line:
我只是遇到了抛出类似错误的问题。就我而言,我使用标准 WEBrick 在 Mac OSX 中以生产模式启动 rails 服务器。由于以下行,它抛出了此错误:
config.serve_static_assets = false
in config/environments/production.rb.
在 config/environments/production.rb 中。
That is set because on most production machines the web server itself will handle this.
这是因为在大多数生产机器上,Web 服务器本身会处理这个问题。
It looks like you were having a different problem, but I'll post this here for others that run into this error.
看起来您遇到了不同的问题,但我会在此处将其发布给遇到此错误的其他人。

