我正在尝试启动并运行新的生产服务器,它非常接近。当我执行
RAILS_ENV=production rake assets:precompile
返回此错误
undefined method `[]' for nil:NilClass
当我使用--trace运行它时,会重新调整
$RAILS_ENV=production rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
undefined method `[]' for nil:NilClass
(in /home/deploy/pm/app/assets/stylesheets/jquery-ui-1.8.16.custom.css.scss)
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
我感谢任何人提供的任何帮助,想法等等。
这是Gemfile和包列表
source 'http://rubygems.org'
gem 'cancan'
gem 'client_side_validations'
gem 'devise', '~> 1.5.3'
gem 'execjs'
gem 'haml'
gem 'httparty'
gem 'jquery-rails'
gem 'mysql2'
gem 'paperclip', "~> 2.4"
gem 'rails', '3.1.0'
gem 'rails3-jquery-autocomplete'
gem 'rake', '0.9.2'
gem 'remotipart', "~> 1.0"
gem 'simple_datatables'
gem 'therubyracer'
gem 'validates_timeliness', '~> 3.0.2'
gem 'will_paginate', '~> 3.0'
gem 'geocoder', '~> 1.1.2'
#temp for pm.onlinetherapy.com
gem 'faker'
group :test do
gem 'capybara'
gem 'cucumber-rails', :require => false
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'faker'
gem 'guard-rspec'
gem 'selenium-webdriver', '2.7.0'
gem 'webrat'
end
group :development, :test do
gem 'faker'
gem 'haml-rails'
gem 'hpricot'
gem 'rspec-rails'
gem 'ruby_parser'
gem 'web-app-theme', '~> 0.8.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sprockets'
gem 'sass', '3.1.20'
gem 'sass-rails', '3.1.4' # downgraded to 3.1.4 to avoid a stack overflow error in rake assets:precompile
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# bundle install has a problem installing linecache19, a dependency of ruby-debug19
# try 'sudo gem install linecache19' to fix the problem, and then do bundle install again
gem 'ruby-debug19', :require => 'ruby-debug'
bundle list
给出了
Gems included by the bundle:
* actionmailer (3.1.0)
* actionpack (3.1.0)
* activemodel (3.1.0)
* activerecord (3.1.0)
* activeresource (3.1.0)
* activesupport (3.1.0)
* archive-tar-minitar (0.5.2)
* arel (2.2.3)
* bcrypt-ruby (3.0.1)
* builder (3.0.2)
* bundler (1.2.0)
* cancan (1.6.8)
* capybara (1.1.2)
* childprocess (0.3.5)
* client_side_validations (3.1.4)
* cocaine (0.3.0)
* coffee-rails (3.1.1)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* columnize (0.3.6)
* cucumber (1.2.1)
* cucumber-rails (1.3.0)
* database_cleaner (0.8.0)
* devise (1.5.3)
* diff-lcs (1.1.3)
* erubis (2.7.0)
* execjs (1.4.0)
* factory_girl (4.0.0)
* factory_girl_rails (4.0.0)
* faker (1.0.1)
* ffi (1.1.5)
* geocoder (1.1.3)
* gherkin (2.11.2)
* guard (1.3.2)
* guard-rspec (1.2.1)
* haml (3.1.7)
* haml-rails (0.3.4)
* hike (1.2.1)
* hpricot (0.8.6)
* httparty (0.8.3)
* i18n (0.6.1)
* jquery-rails (2.1.2)
* json (1.7.5)
* json_pure (1.7.5)
* jsonify (0.3.1)
* jsonify-rails (0.3.2)
* libv8 (3.3.10.4)
* linecache19 (0.5.12)
* listen (0.5.0)
* mail (2.3.3)
* meta_search (1.1.3)
* mime-types (1.19)
* multi_json (1.3.6)
* multi_xml (0.5.1)
* mysql2 (0.3.11)
* nokogiri (1.5.5)
* orm_adapter (0.0.7)
* paperclip (2.7.0)
* polyamorous (0.5.0)
* polyglot (0.3.3)
* rack (1.3.6)
* rack-cache (1.0.3)
* rack-mount (0.8.3)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.1.0)
* rails3-jquery-autocomplete (1.0.9)
* railties (3.1.0)
* rake (0.9.2)
* rdoc (3.12)
* remotipart (1.0.2)
* rspec (2.11.0)
* rspec-core (2.11.1)
* rspec-expectations (2.11.3)
* rspec-mocks (2.11.2)
* rspec-rails (2.11.0)
* ruby-debug-base19 (0.11.25)
* ruby-debug19 (0.11.6)
* ruby_core_source (0.1.5)
* ruby_parser (2.3.1)
* rubyzip (0.9.9)
* sass (3.1.20)
* sass-rails (3.1.4)
* selenium-webdriver (2.7.0)
* sexp_processor (3.2.0)
* simple_datatables (0.2.1)
* sprockets (2.0.4)
* therubyracer (0.10.2)
* thor (0.14.6)
* tilt (1.3.3)
* timeliness (0.3.6)
* treetop (1.4.10)
* tzinfo (0.3.33)
* uglifier (1.3.0)
* validates_timeliness (3.0.14)
* warden (1.2.1)
* web-app-theme (0.8.0)
* webrat (0.7.3)
* will_paginate (3.0.3)
* xpath (0.1.4)
答案 0 :(得分:58)
在我的情况下,我在apps/assets/stylesheet/fonts.css
中创建文件后出现错误
此文件呼叫font-url()
,如:
@font-face {
font-family: 'museo-slab';
src: font-url('museo_slab_500-webfont.eot');
src: font-url('museo_slab_500-webfont.eot?#iefix') format('embedded-opentype'),
font-url('museo_slab_500-webfont.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}
当我将此文件重命名为font.scss
时,错误undefined method '[]' for nil:NilClass
只是消失了
答案 1 :(得分:12)
我遇到了与Cristiam类似的问题。我正在使用Rails 4.0,我在image-url()
文件中调用了.css
。
#pullrefresh .icon.loading {
background: image-url('spinner.png') no-repeat;
width: 19px;
height: 19px;
background-size: 100%;
bottom: 0;
animation: rotate 1s linear infinite;
-o-animation: rotate 1s linear infinite;
-ms-animation: rotate 1s linear infinite;
-moz-animation: rotate 1s linear infinite;
-webkit-animation: rotate 1s linear infinite;
}
我只需将文件重命名为<filename>.scss
,它也适用于我。
答案 2 :(得分:4)
我使用Rails 4.2.8并以这种方式解决了这个问题:
使用key:asset-url在所有项目中查找。
如果css有任何文件,请将其更改为scss。
提交 - &gt;部署。它工作。
答案 3 :(得分:3)
我认为一旦我升级到Rails 3.2.16,这可能已经破裂。我只需要更新sass-rails gem来解决这个问题。
bundle update sass-rails
答案 4 :(得分:2)
我遇到了同样的问题,我通过以下方式解决了这个问题:
.css
文件或类似@
的模式,例如。 @font-face
至.scss
.css.map
个文件(如果有的话).css.map
希望这有助于节省宝贵的时间来调试与样式表相关的资产预编译问题。
答案 5 :(得分:0)
我意识到这是一个旧线程,但它是我搜索查询的最佳结果。
在 rails ~6.0 上,使用加密的秘密(凭据),部署到 Heroku,但这适用于您没有签入 master.key
文件的任何地方(应该无处不在!)
就我而言,我决定使用环境变量来提供 master.key
,但忘记设置变量 RAILS_MASTER_KEY
。