Rails生产服务器:样式表不显示!

时间:2010-10-15 04:34:03

标签: ruby-on-rails css ruby-on-rails-3 routes production

我刚刚从我的开发数据库切换到生产数据库,我意识到我得到的是一致的错误,而不是我尝试打开的视图。尽管样式表位于正确的位置,样式表仍未正确加载。

以下是有关错误的一些信息:

查看

<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" />    

当我尝试从页面源打开“全局”和“主页”样式表时,它们不会打开。我尝试将“public /”添加到URL,但它说没有路由匹配。

位置

所有非http样式表都在root / public / stylesheets /

路线

最后两条路线是'全能',只有网站上的特定功能。这些似乎正在捕捉我的样式表(也可能是其他标签)。

match ':path/:link' => 'welcome#long_switchboard'  
match ':path' => 'welcome#short_switchboard'

1 个答案:

答案 0 :(得分:18)

thread有一些建议......

根据您的网络服务器,您可能需要在config/environments/prodcution.rb中更改以下设置:

config.serve_static_assets = false

要:

config.serve_static_assets = true