【发布时间】:2013-03-13 19:58:47
【问题描述】:
我在生产 Rails 站点上收到 500 内部服务器错误,这就是我在 logs/production.log 上看到的。令人惊讶的是,代码在开发中的本地服务器上工作
Completed 500 Internal Server Error in 11745ms
ActionView::Template::Error (undefined method `[]' for nil:NilClass
(in /home/jason/public_html/site/app/assets/stylesheets/application.css)):
8:
9: <%= csrf_meta_tags %>
10:
11: <%= stylesheet_link_tag "application", :media => "all" %>
12:
13: </head>
14: <body>
app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb__243082314235891573_4889460'
app/controllers/main_controller.rb:18:in `index'
我在这里有点迷路,有什么帮助吗?
这是 Application.css
/* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
/* Main Body */
body {
background: #f3f3f3;
}
【问题讨论】:
-
推送到生产环境时可能需要预编译资产
-
@Jun1st- 如何在生产环境中预编译资产?
-
捆绑 exec rake 资产:预编译。你应该把“如何预编译...”放到谷歌搜索框中,而不是在这里问:)
-
@Jun1st - 顺便说一句,在 config/environments/production.rb 中,它是“config.assets.compile = true”
-
@Jun1st - 我运行了 bundle exec rake assets:precompile,但是得到了这个错误“rake aborted! undefined method `[]' for nil:NilClass (in /home/jason/public_html/mysite/app /assets/stylesheets/application.css) ”,所以基本上和上面一样的错误。
标签: ruby-on-rails ruby-on-rails-3