资产编译在服务器环境中崩溃:“NoMethodError: undefined method `[]' for nil:NilClass" [英] Asset compiling crashing on server environment with: "NoMethodError: undefined method `[]' for nil:NilClass"

查看:55
本文介绍了资产编译在服务器环境中崩溃:“NoMethodError: undefined method `[]' for nil:NilClass"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了这个,我一直在拔头发.我一直和资产管道关系不好,它总是给我带来麻烦..今天又来了..

I've been pulling my hair out for this one. I've always had a bad relationship with the asset-pipeline, it is always giving me trouble.. And today again..

当我尝试在本地编译我的资产时,一切都很好:

When I try and compile my assets locally, everything is fine:

$ RAILS_ENV=production rake assets:precompile --trace

但是当我使用 Capistrano 进行部署时:

But when I deploy with Capistrano which does:

cd /var/www/xxx/releases/20140717164232 && ( RAILS_ENV=production bundle exec rake assets:precompile )

它因以下错误而崩溃:

rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
  (in /var/www/xxx/releases/20140717164232/app/assets/stylesheets/application-sign-in.css)
/var/www/xxx/shared/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/sass_functions.rb:63:in `sprockets_context'

我真的不知道如何调试这个..在本地我无法重现它并且在我的服务器上错误只是没有指向我任何地方..

I seriously do not know how to debug this.. Locally I can't reproduce it and on my server the error is just not pointing me anywhere..

我搜索了错误并尝试了几件事,但没有任何帮助.有人说通过更新错误会消失......或者在 sass-rails gem 之前添加 sprockets gem.

I've searched for the error and tried a couple things but nothing helped. Some say the error is going away by updating.. Or by adding the sprockets gem before the sass-rails gem.

我的项目设置如下;一个常规的 Rails 4 应用程序,带有一个 gem,其中包含代表模板的资产.我使用以下行来确保所有内容都已编译:

My project is setup like the following; A regular rails 4 app with a gem containing assets representing a template. I use the following line to make sure everything is compiled:

config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.css *.js *.eot *.woff *.ttf *.svg)

有谁知道如何解决这个问题,或者如何调试它?

Anyone that knows how to solve this, or how to debug it?

编辑

删除所有 asset-url() 助手似乎有效.. 但同样,不知道为什么..

Removing all asset-url() helper seems to work.. But again, no clue why..

推荐答案

我遇到了同样的问题,结果是一个包含 asset-url 的 css 文件没有 .scss 扩展.奇怪的是,我可以在本地编译资产,但不能在服务器上编译.

I had the samme issue and it turned out to be a css file containing asset-url that didnt have the .scss extension. Weirdly I could compile the assets locally but not on the server.

这篇关于资产编译在服务器环境中崩溃:“NoMethodError: undefined method `[]' for nil:NilClass"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆