500内部服务器错误 - Rails生产中的ActionView :: Template ::错误

时间:2013-03-24 07:28:05

标签: ruby-on-rails ruby-on-rails-3

我的生产轨道网站上出现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;
}

2 个答案:

答案 0 :(得分:3)

您需要在推送到生产时预编译资产

bundle exec rake assets:precompile

另外,请阅读asset pipeline doc,值得您花些时间

答案 1 :(得分:0)

对于像我这样的人,他们在遇到类似错误后最终在这里住了,但没有堆栈跟踪:better_errors宝石为我提供了解决此问题的信息。