rake资产预编译突然失败

时间:2014-03-16 20:42:50

标签: ruby-on-rails heroku

rake aborted!
undefined method 'environment' for nil:NilClass
(in /tmp/build_ae55b983-43e6-4074-8c54-6f05382a3ec4/app/assets/stylesheets/custom.css.scss)
/tmp/build_ae55b983-43e6-4074-8c54-6f05382a3ec4/vendor/bundle/ruby/1.9.1/gems/sass-rails-4.0.1/lib/sass/rails/importer.rb:84:in 'evaluate'
and so forth...

我发布了我的custom.css.scss文件,以防问题出现,但它与教程中发布的代码相符,所以我不认为这是问题所在。这是Michael Hertl的Ruby on Rails教程的第9章,这是我在尝试推送到heroku时遇到的第一个问题。该应用程序在本地运行,但不会推送到Heroku。我尝试按照另一篇文章的建议将sprockets gem更改为2.11.0,但它没有解决问题。

custom.css.scss

@import "bootstrap";

/* mixins, variables, etc. */

$grayMediumLight: #eaeaea;

@mixin box_sizing {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  }

/* universal */

html {
  overflow-y: scroll;
  }

body {
  padding-top: 60px;
  }

section{
  overflow: auto;
  }

textarea {
  resize: vertical;
  }

.center {
  text-align: center;
  h1 {
    margin-bottom: 10px;
    }
  }

/* typography */

h1, h2, h3, h4, h5, h6 {
  line-height: 1;
  }

h1 {
  font-size: 3em;
  letter-spacing: -2px;
  margin-bottom: 30px;
  text-align: center;
  }

h2 {
  font-size: 1.2em;
  letter-spacing: -1px;
  margin-bottom: 30px;
  text-align: center;
  font-weight: normal;
  color: $grayLight;
  }

p { 
  font-size: 1.1em;
  line-height: 1.7em;
  }

/* header */

#logo {
  float: left;
  margin-right: 10px;
  font-size: 1.7em;
  color: white;
  text-transform: uppercase;
  letter-spacing: -1px;
  padding-top: 9px;
  font-weight: bold;
  line-height: 1;
  &:hover {
    color: white;
    text-decoration: none;
    }
  }

/* footer */

footer {
  margin-top: 45px;
  padding-top: 5px;
  border-top: 1px solid $grayMediumLight;
  color: $grayLight;
  a {
    color: $gray;
    &:hover {
      color: $grayDarker;
    } 
  }
  small {
    float: left;
    }
  ul {
    float: right;
    list-style: none;
    li {
      float: left;
      margin-left: 10px;
      }
    }
  }

/* sidebar */

aside {
  section {
    padding: 10px 0;
    border-top: 1px solid $grayLighter;
    &:first-child {
      border: 0;
      padding-top: 0;
      }
    span {
      display: block;
      margin-bottom: 3px;
      line-height: 1;
      }
    h1 {
      font-size: 1.4em;
      text-align: left;
      letter-spacing: -1px;
      margin-bottom: 3px;
      margin-top: 0px;
      }
    }
  }

.gravatar {
  float: left;
  margin-right: 10px;
  }

/* miscellaneous */

.debug_dump {
  clear: both;
  float: left;
  width: 100%;
  margin-top: 45px;
  @include box_sizing;
  } 

/* forms */

input, textarea, select, .uneditable-input {
  border: 1px solid #bbb;
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  @include box_sizing;
  }

input {
  height: auto !important;
  }

#error_explanation {
  color: #f00;
  ul {
    list-style: none;
    margin: 0 0 18px 0;
    }
  }

.field_with_errors {
  @extend .control-group;
  @extend .error;
  }

/* Users index */

.users {
  list-style: none;
  margin: 0;
  li {
    overflow: auto;
    padding: 10px 0;
    border-top: 1px solid $grayLighter;
    &:last-child {
      border-bottom: 1px solid $grayLighter;
    }
  }
}

的Gemfile:

source 'https://rubygems.org'
ruby '1.9.3'
#ruby-gemset=railstutorial_rails_4_0

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'

# Use sqlite3 as the database for Active Record
group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
  gem 'cucumber-rails', '1.4.0', :require => false
  gem 'database_cleaner', github: 'bmabey/database_cleaner'
end

# Use SCSS for stylesheets
gem 'sass-rails', '4.0.1'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails', '3.0.4'

# Turbolinks makes following links in your web application faster. Read more: #https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]e here

1 个答案:

答案 0 :(得分:0)

我在本周早些时候遇到了这个问题,zurb-foundation在我正在更新的旧rails应用程序上,也是一个新的测试应用程序。在使用gem版本搞乱之后,我使用rvm创建了一个新的gemset并重新运行了bundler。一切都很顺利。