我刚刚从开发数据库切换到生产数据库,然后发现无论我尝试打开哪个视图,都会出现一个持续的错误。尽管样式表位于正确的位置,但它们未能正确加载。
以下是关于这个错误的一些信息:
视图
<head>
<%= stylesheet_link_tag "global", "home", "http://static.flowplayer.org/tools/css/scrollable-navig.css" %>
</head>
控制台
Started GET "/stylesheets/global.css?1287048448" for 127.0.0.1 at 2010-10-15 00:18:43 -0400
Processing by WelcomeController#long_switchboard as CSS
Parameters: {"1287048448"=>nil, "path"=>"stylesheets", "link"=>"global"}
Completed in 2ms
NoMethodError (undefined method `id' for nil:NilClass):
app/controllers/welcome_controller.rb:76:in `long_switchboard'
Rendered C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (7.0ms)
Rendered C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (108.0ms)
页面源代码
<link href="/stylesheets/global.css?1287048448" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/home.css?1287086704" media="screen" rel="stylesheet" type="text/css" />
<link href="http://static.flowplayer.org/tools/css/scrollable-navig.css" media="screen" rel="stylesheet" type="text/css" />
当我尝试从页面源代码中打开“global”和“home”样式表时,它们无法打开。我尝试将“public/”添加到URL中,但它显示没有匹配的路由。
位置
所有非HTTP样式表都在根目录下的public/stylesheets/。
路由
最后两个路由是“catch-all”路由,仅用于网站上的特定功能。这些路由似乎捕获了我的样式表(以及可能是其他标签)。
match ':path/:link' => 'welcome#long_switchboard'
match ':path' => 'welcome#short_switchboard'
routes.rb
文件中... 确保/stylesheets
,/images
,/javascripts
等路径不被 'catch-all' 路由所捕获。如果您需要修复此问题,请发布您的routes.rb
文件以获取建议。 - Mischa