没有路由匹配css文件的[GET]错误

时间:2011-10-04 13:52:04

标签: ruby-on-rails ruby-on-rails-3.1

运行rails server时出现以下错误:

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

这是development.rb文件:

Depot::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local       = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true

end

routes.rb文件:

Depot::Application.routes.draw do
get "store/index"

resources :products    
root :to => 'store#index', :as => 'store'
end

我尝试输入“config.serve_static_assets = true”但它没有帮助。有谁知道出了什么问题?

1 个答案:

答案 0 :(得分:2)

你可能在某个地方弄乱了路线,或者你有一个名为assets_controller的控制器或其他导致命名与路径/assets/scaffold.css发生冲突的东西本质上错误告诉你{ {1}}被解释为/assets/scaffold.css - 意思是......

它认为/controller/action.format存在,并且您尝试调用assets_controller操作,请求scaffold格式的回复。

另外,请确保您的.css文件按此路径位于scaffold.css