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

发布于 2024-09-27 22:07:45 字数 1857 浏览 5 评论 0原文

我刚刚从开发数据库切换到生产数据库,我意识到无论我尝试打开哪个视图,都会遇到一致的错误。尽管样式表位于正确的位置,但未正确加载。

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

查看

<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'

I just switched over from my development database to the production database, and I realized I'm getting a consistent error nomatter what view I try to open. The stylesheets are not loading correctly, despite being in the correct place.

Here's some information about the error:

View

<head>
<%= stylesheet_link_tag "global", "home", "http://static.flowplayer.org/tools/css/scrollable-navig.css" %>
</head>

Console

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)

Page Source

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

When I try to open the 'global' and 'home' stylesheets from the page source, they are not opened. I tried adding 'public/' to the URL but it says no route matches.

Location

All non-http stylesheets are in root/public/stylesheets/

Routes

The last two routes are the 'catch-alls', only there for a particular feature on the site. These seem to be catching my stylesheets (and possibly other tags too).

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山有枢 2024-10-04 22:07:46

线程有一些建议...

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

config.serve_static_assets = false

To:

config.serve_static_assets = true

This thread has some suggestions...

Depending on your webserver you may have to change the following setting in config/environments/prodcution.rb from:

config.serve_static_assets = false

To:

config.serve_static_assets = true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文