RoR路由错误

时间:2011-11-12 12:48:30

标签: ruby-on-rails ruby

我已将我的css放在stylesheets文件夹中,并将图像放在images文件夹中。这两个文件夹都在我的rails应用程序的公共文件夹中。但是,我一直收到这些错误:

Started GET "/assets/blueprint/print.css" for 127.0.0.1 at Sat Nov 12 07:36:49 -0500 2011
Served asset /blueprint/print.css - 404 Not Found (2ms)

ActionController::RoutingError (No route matches [GET] "/assets/blueprint/print.css"):


Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.3ms)


Started GET "/assets/custom.css" for 127.0.0.1 at Sat Nov 12 07:36:49 -0500 2011
Served asset /custom.css - 404 Not Found (2ms)

ActionController::RoutingError (No route matches [GET] "/assets/custom.css"):


Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.4ms)


Started GET "/assets/logo.png" for 127.0.0.1 at Sat Nov 12 07:36:49 -0500 2011
Served asset /logo.png - 404 Not Found (3ms)

ActionController::RoutingError (No route matches [GET] "/assets/logo.png"):

我做错了什么?感谢。

2 个答案:

答案 0 :(得分:2)

看起来你正在使用3.1。尝试将stylesheet和js文件放在assets目录下。请参阅有关如何使用资产管道here

的部分

答案 1 :(得分:1)

我有一个类似的问题试图获得正确的资产,但我正在使用 Rails 3.2.6。这对我有用:

gem install sprockets

然后

bundle install

来源:http://guides.rubyonrails.org/asset_pipeline.html#how-to-use-the-asset-pipeline